ng-repeat finish event

前端 未结 15 2961
盖世英雄少女心
盖世英雄少女心 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:54

    If you simply want to execute some code at the end of the loop, here's a slightly simpler variation that doesn't require extra event handling:

    thing {{thing}}
    function Ctrl($scope) {
      $scope.things = [
        'A', 'B', 'C'  
      ];
    }
    
    angular.module('myApp', [])
    .directive('myPostRepeatDirective', function() {
      return function(scope, element, attrs) {
        if (scope.$last){
          // iteration is complete, do whatever post-processing
          // is necessary
          element.parent().css('border', '1px solid black');
        }
      };
    });
    

    See a live demo.

提交回复
热议问题