관리 메뉴

moozi

AngularJS Custom Filter 예제 본문

TIS_2016/HTML5_1기

AngularJS Custom Filter 예제

moozi 2016. 3. 23. 15:35

<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/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 result="";
        result=x.replace(",","-가격:")
       
        return result;
    };
});
app.controller('namesCtrl', function($scope) {
    $scope.names = [
        '자전거,2000',
        '자동차,3000',
        'TV,5000'
        ];
});
</script>


</body>
</html>

'TIS_2016 > HTML5_1기' 카테고리의 다른 글

jquery 연습문제1  (0) 2016.03.24
gallery프로그램 예제  (0) 2016.03.24
파이차트그리기  (0) 2016.03.22
3/22 javascript canvas예제  (0) 2016.03.22
javascript 연습문제3  (0) 2016.03.21
Comments