當ng-重復完成時調用一個函數。我試圖實現的基本上是一個“onng重復完成的呈現”處理程序。我能夠檢測它何時完成,但我不知道如何從它觸發一個函數。檢查小提琴:http://jsfiddle.net/paulocoelho/BsMqq/3/JSvar 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");
}}HTML<div ng-app="testApp" ng-controller="myC">
<p ng-repeat="t in ta" on-finish-render="test()">{{t}}</p></div>回答*最后一步的工作小提琴:http://jsfiddle.net/paulocoelho/BsMqq/4/
添加回答
舉報
0/150
提交
取消