AngularJS Filters 맞춤 필터
AngularJS Filters 맞춤 필터
모듈에 새 필터 팩토리 함수를 등록하여 고유 한 필터를 만들 수 있습니다.
"myFormat"이라는 사용자 정의 필터를 만듭니다.
<ul ng-app="myApp" ng-controller="namesCtrl">
<li ng-repeat="x in names">
{{x | myFormat}}
</li>
</ul>
<script>
var app = angular.module('myApp', []);
app.filter('myFormat', function() {
return function(x) {
var i, c, txt = "";
for (i = 0; i < x.length; i++) {
c = x[i];
if (i % 2 == 0) {
c = c.toUpperCase();
}
txt += c;
}
return txt;
};
});
app.controller('namesCtrl', function($scope) {
$scope.names = ['Jani', 'Carl', 'Margareth', 'Hege', 'Joe', 'Gustav', 'Birgit', 'Mary', 'Kai'];
});
</script>
myFormat필터는 다른 모든 문자를 대문자로 포맷합니다.
[전체소스]
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body>
<ul ng-app="myApp" ng-controller="namesCtrl">
<li ng-repeat="x in names">
{{x | myFormat}}
</li>
</ul>
<script>
var app = angular.module('myApp', []);
app.filter('myFormat', function() {
return function(x) {
var i, c, txt = "";
for (i = 0; i < x.length; i++) {
c = x[i];
if (i % 2 == 0) {
c = c.toUpperCase();
}
txt += c;
}
return txt;
};
});
app.controller('namesCtrl', function($scope) {
$scope.names = [
'Jani',
'Carl',
'Margareth',
'Hege',
'Joe',
'Gustav',
'Birgit',
'Mary',
'Kai'
];
});
</script>
<p>Make your own filters.</p>
<p>This filter, called "myFormat", will uppercase every other character.</p>
</body>
</html>
모듈에 새 필터 팩토리 함수를 등록하여 고유 한 필터를 만들 수 있습니다.
"myFormat"이라는 사용자 정의 필터를 만듭니다.
<ul ng-app="myApp" ng-controller="namesCtrl">
<li ng-repeat="x in names">
{{x | myFormat}}
</li>
</ul>
<script>
var app = angular.module('myApp', []);
app.filter('myFormat', function() {
return function(x) {
var i, c, txt = "";
for (i = 0; i < x.length; i++) {
c = x[i];
if (i % 2 == 0) {
c = c.toUpperCase();
}
txt += c;
}
return txt;
};
});
app.controller('namesCtrl', function($scope) {
$scope.names = ['Jani', 'Carl', 'Margareth', 'Hege', 'Joe', 'Gustav', 'Birgit', 'Mary', 'Kai'];
});
</script>
myFormat필터는 다른 모든 문자를 대문자로 포맷합니다.
[전체소스]
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body>
<ul ng-app="myApp" ng-controller="namesCtrl">
<li ng-repeat="x in names">
{{x | myFormat}}
</li>
</ul>
<script>
var app = angular.module('myApp', []);
app.filter('myFormat', function() {
return function(x) {
var i, c, txt = "";
for (i = 0; i < x.length; i++) {
c = x[i];
if (i % 2 == 0) {
c = c.toUpperCase();
}
txt += c;
}
return txt;
};
});
app.controller('namesCtrl', function($scope) {
$scope.names = [
'Jani',
'Carl',
'Margareth',
'Hege',
'Joe',
'Gustav',
'Birgit',
'Mary',
'Kai'
];
});
</script>
<p>Make your own filters.</p>
<p>This filter, called "myFormat", will uppercase every other character.</p>
</body>
</html>
게시판 목록
퍼블리싱강좌
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 58 | jQuery Mobile | 8년 전 | 2982 | ||
| 57 | jQuery Mobile | 8년 전 | 2024 | ||
| 56 | jQuery Mobile | 8년 전 | 1358 | ||
| 55 | jQuery Mobile | 8년 전 | 1552 | ||
| 54 | jQuery Mobile | 8년 전 | 2232 | ||
| 53 | jQuery Mobile | 8년 전 | 1533 | ||
| 52 | jQuery Mobile | 8년 전 | 1551 | ||
| 51 | jQuery Mobile | 8년 전 | 1422 | ||
| 50 | jQuery Mobile | 8년 전 | 1311 | ||
| 49 | jQuery Mobile | 8년 전 | 1816 | ||
| 48 | jQuery Mobile | 8년 전 | 1459 | ||
| 47 | jQuery Mobile | 8년 전 | 2016 | ||
| 46 | jQuery Mobile | 8년 전 | 1978 | ||
| 45 | jQuery Mobile | 8년 전 | 1509 | ||
| 44 | jQuery Mobile | 8년 전 | 1670 | ||
| 43 | jQuery Mobile | 8년 전 | 1785 | ||
| 42 | jQuery Mobile | 8년 전 | 1664 | ||
| 41 | jQuery Mobile | 8년 전 | 1832 | ||
| 40 | jQuery Mobile | 8년 전 | 1473 | ||
| 39 | jQuery Mobile | 8년 전 | 1630 | ||
| 38 | jQuery Mobile | 8년 전 | 2179 | ||
| 37 | jQuery Mobile | 8년 전 | 2678 | ||
| 36 | jQuery Mobile | 8년 전 | 2130 | ||
| 35 | jQuery Mobile | 8년 전 | 1515 | ||
| 34 | jQuery Mobile | 8년 전 | 2420 | ||
| 33 | AngularJS | 8년 전 | 2867 | ||
| 32 | AngularJS | 8년 전 | 2428 | ||
| 31 | AngularJS | 8년 전 | 1765 | ||
| 30 | AngularJS | 8년 전 | 2837 | ||
| 29 | AngularJS | 8년 전 | 2396 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기