AngularJS监听DOM加载完毕

直接上代码:

Module.directive('renderFinish', function ($timeout) {      //renderFinish自定义指令
    return {
        restrict: 'A',
        link: function(scope, element, attr) {
            if (scope.$last === true) {
                $timeout(function() {
                    scope.$emit('ngRepeatFinished');
                });
            }
        }
    };
});
/* 控制器 */
nassModule.controller('mallHome', ['$scope', '$http', function($scope, $http) {

    $scope.$on('ngRepeatFinished', function(){
        $scope.funName();
    });

}]);

 

<li ng-repeat="item in data.focus" render-finish>content</li>

 

posted @ 2016-08-03 23:15  程序大大  阅读(11363)  评论(0编辑  收藏  举报