AngularJS监听ng-repeat渲染完成的两种方法
本文实例讲述了AngularJS监听ng-repeat渲染完成的两种方法。分享给大家供大家参考,具体如下:
监听ng-repeat渲染完成有两种方法
一、最实用的方法:
对应作用域controller:
$scope.completeRepeate=function(){
alert('1')
}
自定义指令directive:
varapp=angular.moduler('myApp',[]);
app.directive('onFinishRenderFilters',['$timeout',function($timeout){
return{
restrict:'A',
link:function(scope,element,attr){
if(scope.$last===true){
varfinishFunc=scope.$parent[attr.onFinishRenderFilters];
if(finishFunc)
{
finishFunc();
}
}
}
};
}])
二、使用广播事件
/*
*Controller文件中的代码
*Setupgeneralpagecontroller
*/
MetronicApp.controller('simpleManageController',['$rootScope',
'$scope','settings','$http',function($rootScope,$scope,settings,$http){
$scope.$on('ngRepeatFinished',function(ngRepeatFinishedEvent){
//下面是在tablerender完成后执行的js
FormEditable.init();
Metronic.stopPageLoading();
$(".simpleTab").show();
});
});
MetronicApp.directive('onFinishRenderFilters',function($timeout){
return{
restrict:'A',
link:function(scope,element,attr){
if(scope.$last===true){
$timeout(function(){
scope.$emit('ngRepeatFinished');
});
}
}
};
});
HTML
{{simpleProduct.productNo}}
更多关于AngularJS相关内容感兴趣的读者可查看本站专题:《AngularJS指令操作技巧总结》、《AngularJS入门与进阶教程》及《AngularJSMVC架构总结》
希望本文所述对大家AngularJS程序设计有所帮助。
热门推荐
4 狗狗请人训练
5 训练狗狗迎宾
6 训练狗狗解放
7 抬头训练狗狗
10 训练狗狗的基本动作
11 两个月狗狗怎么训练大小便
12 教狗狗训练
13 记叙文训练狗狗
14 潮州训练狗狗
15 训练狗狗叫的方法
16 猫训练狗狗
17 狗狗训练如厕
18 狗狗来训练