Angular.js Filters 2


Angular.js Filters 2

조건 for문 돌리기 <ul ng-app="App" ng-controller="Ctrl"> <li ng-repeat="x in names"> {{x | Format}} </li> </ul> <script> var app = angular.module('App', []); app.filter('Format', function() { return function(x) { var i, c, txt = ""; for (i = 0; i < x.length; i++) { c = x[i]; if (i % 3 == 0) { c = c.toUpperCase(); } txt += c; } return txt; }; }); app.controller('Ctrl', function($scope) { $scope.names = ['jaki', 'JAKI', 'Golila', 'dog', 'TIGHER', 'RABBIT', 'bee', 'CAT', 'TUrtle']; }); </script>...



원문링크 : Angular.js Filters 2