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>
게시판 목록
퍼블리싱강좌
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 298 | CSS |
선택과집중
|
2개월 전 | 159 | |
| 297 | CSS |
선택과집중
|
3개월 전 | 360 | |
| 296 | CSS |
선택과집중
|
3개월 전 | 312 | |
| 295 | CSS |
선택과집중
|
4개월 전 | 292 | |
| 294 | CSS |
선택과집중
|
4개월 전 | 422 | |
| 293 | CSS |
선택과집중
|
4개월 전 | 371 | |
| 292 | CSS |
선택과집중
|
4개월 전 | 292 | |
| 291 | CSS |
선택과집중
|
5개월 전 | 295 | |
| 290 | CSS |
선택과집중
|
5개월 전 | 343 | |
| 289 | CSS |
선택과집중
|
5개월 전 | 314 | |
| 288 | CSS |
선택과집중
|
5개월 전 | 400 | |
| 287 | CSS |
선택과집중
|
5개월 전 | 347 | |
| 286 | CSS |
선택과집중
|
5개월 전 | 348 | |
| 285 | CSS |
선택과집중
|
5개월 전 | 366 | |
| 284 | CSS |
선택과집중
|
5개월 전 | 256 | |
| 283 | CSS |
|
2년 전 | 1526 | |
| 282 | CSS | 2년 전 | 2504 | ||
| 281 | CSS | 4년 전 | 4035 | ||
| 280 | CSS | 4년 전 | 4557 | ||
| 279 | 반응형웹 | 5년 전 | 2985 | ||
| 278 | 반응형웹 | 5년 전 | 2834 | ||
| 277 | 부트스트랩 | 7년 전 | 5033 | ||
| 276 | 부트스트랩 | 7년 전 | 6589 | ||
| 275 | 부트스트랩 | 7년 전 | 4671 | ||
| 274 | 부트스트랩 | 7년 전 | 6700 | ||
| 273 | 부트스트랩 | 7년 전 | 3366 | ||
| 272 | 부트스트랩 | 7년 전 | 3206 | ||
| 271 | 부트스트랩 | 7년 전 | 3707 | ||
| 270 | 부트스트랩 | 7년 전 | 3233 | ||
| 269 | 부트스트랩 | 7년 전 | 3108 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기