相关疑难解决方法(0)

ng-repeat完成后调用函数

我想要实现的基本上是"on ng repeat finished rendering"处理程序.我能够检测到它何时完成,但我无法弄清楚如何从中触发一个功能.

检查小提琴:http://jsfiddle.net/paulocoelho/BsMqq/3/

JS

var module = angular.module('testApp', [])
    .directive('onFinishRender', function () {
    return {
        restrict: 'A',
        link: function (scope, element, attr) {
            if (scope.$last === true) {
                element.ready(function () {
                    console.log("calling:"+attr.onFinishRender);
                    // CALL TEST HERE!
                });
            }
        }
    }
});

function myC($scope) {
    $scope.ta = [1, 2, 3, 4, 5, 6];
    function test() {
        console.log("test executed");
    }
}
Run Code Online (Sandbox Code Playgroud)

HTML

<div ng-app="testApp" ng-controller="myC">
    <p ng-repeat="t in ta" on-finish-render="test()">{{t}}</p>
</div>
Run Code Online (Sandbox Code Playgroud)

答案:来自finishmove的工作小提琴:http …

events directive handler ready angularjs

250
推荐指数
5
解决办法
14万
查看次数

标签 统计

angularjs ×1

directive ×1

events ×1

handler ×1

ready ×1