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>
게시판 목록
퍼블리싱강좌
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 28 | 반응형웹 | 9년 전 | 4495 | ||
| 27 | 반응형웹 | 9년 전 | 7563 | ||
| 26 | 부트스트랩 |
|
10년 전 | 14833 | |
| 25 | 부트스트랩 |
|
10년 전 | 9426 | |
| 24 | 표준화 | 11년 전 | 8296 | ||
| 23 | 반응형웹 | 12년 전 | 13496 | ||
| 22 | 표준화 | 12년 전 | 9470 | ||
| 21 | 표준화 | 12년 전 | 16757 | ||
| 20 | 반응형웹 | 13년 전 | 19691 | ||
| 19 | 반응형웹 | 13년 전 | 31016 | ||
| 18 | 반응형웹 | 13년 전 | 36491 | ||
| 17 | 표준화 | 13년 전 | 12912 | ||
| 16 | 반응형웹 | 13년 전 | 29311 | ||
| 15 | 반응형웹 | 13년 전 | 11844 | ||
| 14 | 반응형웹 | 13년 전 | 31758 | ||
| 13 | 반응형웹 | 13년 전 | 29737 | ||
| 12 | 반응형웹 | 13년 전 | 39246 | ||
| 11 | 반응형웹 | 13년 전 | 50643 | ||
| 10 | 반응형웹 | 13년 전 | 32789 | ||
| 9 | 표준화 | 13년 전 | 9157 | ||
| 8 | 표준화 | 13년 전 | 11236 | ||
| 7 | 표준화 | 13년 전 | 9174 | ||
| 6 | 표준화 | 13년 전 | 11143 | ||
| 5 | 표준화 | 13년 전 | 11244 | ||
| 4 | 표준화 | 13년 전 | 14720 | ||
| 3 | 표준화 | 13년 전 | 8073 | ||
| 2 | 표준화 | 13년 전 | 10176 | ||
| 1 | 표준화 | 13년 전 | 11910 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기