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>
게시판 목록
퍼블리싱강좌
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 88 | jQuery Mobile | 8년 전 | 1932 | ||
| 87 | jQuery Mobile | 8년 전 | 1912 | ||
| 86 | jQuery Mobile | 8년 전 | 1518 | ||
| 85 | jQuery Mobile | 8년 전 | 1831 | ||
| 84 | jQuery Mobile | 8년 전 | 1866 | ||
| 83 | jQuery Mobile | 8년 전 | 1882 | ||
| 82 | jQuery Mobile | 8년 전 | 1653 | ||
| 81 | jQuery Mobile | 8년 전 | 1370 | ||
| 80 | jQuery Mobile | 8년 전 | 1806 | ||
| 79 | jQuery Mobile | 8년 전 | 1355 | ||
| 78 | jQuery Mobile | 8년 전 | 1753 | ||
| 77 | jQuery Mobile | 8년 전 | 1779 | ||
| 76 | jQuery Mobile | 8년 전 | 1788 | ||
| 75 | jQuery Mobile | 8년 전 | 1399 | ||
| 74 | jQuery Mobile | 8년 전 | 1539 | ||
| 73 | jQuery Mobile | 8년 전 | 1246 | ||
| 72 | jQuery Mobile | 8년 전 | 1628 | ||
| 71 | jQuery Mobile | 8년 전 | 1621 | ||
| 70 | jQuery Mobile | 8년 전 | 1504 | ||
| 69 | jQuery Mobile | 8년 전 | 1510 | ||
| 68 | jQuery Mobile | 8년 전 | 2046 | ||
| 67 | jQuery Mobile | 8년 전 | 1315 | ||
| 66 | jQuery Mobile | 8년 전 | 1691 | ||
| 65 | jQuery Mobile | 8년 전 | 1183 | ||
| 64 | jQuery Mobile | 8년 전 | 1467 | ||
| 63 | jQuery Mobile | 8년 전 | 1655 | ||
| 62 | jQuery Mobile | 8년 전 | 1634 | ||
| 61 | jQuery Mobile | 8년 전 | 1875 | ||
| 60 | jQuery Mobile | 8년 전 | 1407 | ||
| 59 | jQuery Mobile | 8년 전 | 1964 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기