ng-repeat finish event

前端 未结 15 2619
盖世英雄少女心
盖世英雄少女心 2020-11-22 02:15

I want to call some jQuery function targeting div with table. That table is populated with ng-repeat.

When I call it on

$(document).r         


        
15条回答
  •  隐瞒了意图╮
    2020-11-22 02:36

    This is an improvement of the ideas expressed in other answers in order to show how to gain access to the ngRepeat properties ($index, $first, $middle, $last, $even, $odd) when using declarative syntax and isolate scope (Google recommended best practice) with an element-directive. Note the primary difference: scope.$parent.$last.

    angular.module('myApp', [])
    .directive('myRepeatDirective', function() {
      return {
        restrict: 'E',
        scope: {
          someAttr: '='
        },
        link: function(scope, element, attrs) {
          angular.element(element).css('color','blue');
          if (scope.$parent.$last){
            window.alert("im the last!");
          }
        }
      };
    });
    

提交回复
热议问题