ng-repeat finish event

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

    Maybe a bit simpler approach with ngInit and Lodash's debounce method without the need of custom directive:

    Controller:

    $scope.items = [1, 2, 3, 4];
    
    $scope.refresh = _.debounce(function() {
        // Debounce has timeout and prevents multiple calls, so this will be called 
        // once the iteration finishes
        console.log('we are done');
    }, 0);
    

    Template:

    • {{item}}

    Update

    There is even simpler pure AngularJS solution using ternary operator:

    Template:

    • {{item}}

    Be aware that ngInit uses pre-link compilation phase - i.e. the expression is invoked before child directives are processed. This means that still an asynchronous processing might be required.

提交回复
热议问题