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년 전 | 4489 | ||
| 27 | 반응형웹 | 9년 전 | 7558 | ||
| 26 | 부트스트랩 |
|
10년 전 | 14831 | |
| 25 | 부트스트랩 |
|
10년 전 | 9424 | |
| 24 | 표준화 | 11년 전 | 8296 | ||
| 23 | 반응형웹 | 12년 전 | 13493 | ||
| 22 | 표준화 | 12년 전 | 9467 | ||
| 21 | 표준화 | 12년 전 | 16755 | ||
| 20 | 반응형웹 | 13년 전 | 19690 | ||
| 19 | 반응형웹 | 13년 전 | 31007 | ||
| 18 | 반응형웹 | 13년 전 | 36485 | ||
| 17 | 표준화 | 13년 전 | 12909 | ||
| 16 | 반응형웹 | 13년 전 | 29306 | ||
| 15 | 반응형웹 | 13년 전 | 11840 | ||
| 14 | 반응형웹 | 13년 전 | 31752 | ||
| 13 | 반응형웹 | 13년 전 | 29734 | ||
| 12 | 반응형웹 | 13년 전 | 39242 | ||
| 11 | 반응형웹 | 13년 전 | 50636 | ||
| 10 | 반응형웹 | 13년 전 | 32781 | ||
| 9 | 표준화 | 13년 전 | 9156 | ||
| 8 | 표준화 | 13년 전 | 11230 | ||
| 7 | 표준화 | 13년 전 | 9168 | ||
| 6 | 표준화 | 13년 전 | 11136 | ||
| 5 | 표준화 | 13년 전 | 11239 | ||
| 4 | 표준화 | 13년 전 | 14714 | ||
| 3 | 표준화 | 13년 전 | 8063 | ||
| 2 | 표준화 | 13년 전 | 10173 | ||
| 1 | 표준화 | 13년 전 | 11903 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기