Call function when ng-repeat has finished AngularJS

var module = angular.module('app', [])
    .directive('onFinishRender', function ($timeout) {
    return {
        restrict: 'A',
        link: function (scope, element, attr) {
            if (scope.$last === true) {
                $timeout(function () {
                    scope.$emit(attr.onFinishRender);
                });
            }
        }
    }
});

On controller

$scope.$on('ngRepeatFinished', function(ngRepeatFinishedEvent) {
    //you also get the actual event object
    //do stuff, execute functions -- whatever...
});

Template

<div ng-repeat="item in items" on-finish-render="ngRepeatFinished">
    <div>}<div>
</div>

Sumber

Written on February 6, 2017