angularjs 사용법 공부
(3일 리뷰 준비)
.filter(...)
함수를 이용하여 사용자 정의 필터 추가 가능
filterProvider
사용-
이나 .
은 허용되지 않는다 (표현식 이름 규칙과 동일)
angular
.module('core')
.controller('FilterController', ['$scope', function($scope) {
$scope.checked = true
}])
.filter('checkmark', function(){
return function(input, colored){
if(colored){ // colored is truthy
console.log('colored')
return input ? '\\u2705' : '\\u274c'
}
return input ? '\\u2713' : '\\u2718'
}
})
<div ng-controller="FilterController">
<p>
checked
<input type="checkbox" name="checked" id="checked" ng-model="checked">
</p>
<p>
colored
<input type="checkbox" name="colored" id="colored" ng-model="colored">
</p>
checkmark filter: {{ checked | checkmark:colored }}
</div>