1 2 3 4 5 6 7 8 9 10 11 12 13 | var cling = angular.module('cling', []); cling.controller( 'exampleCtrl',function ($scope) { $scope.items = [ 'angular', 'node', 'mongo' ]; }); <div ng-repeat="item in items"> tool : {{item}} </div> | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | cling.directive('callFunction', function () { return { restrict: 'A', link: function ($scope, $element, $attr) { if ($scope.$first) { console.log('first item printed'); console.log('call function 1'); } else if ($scope.$last) { console.log('last item printed'); console.log('call function 2'); } } } }); <div ng-repeat="item in items" call-function> tool : {{item}} </div> | cs |
1 2 3 4 5 6 7 8 | <div ng-repeat = 'list in data'> <div ng-if='{{$index}} == 0'> // ng-reapat 가 처음일때 // 내용 1 </div> <div ng-if='{{$index}} == data.length-1'> // ng-reapat 가 마지막일때 // 내용 2 </div> </div> | cs |
출처 | 나 |