美文网首页
检测ng-repeat finish

检测ng-repeat finish

作者: 幸福幸福幸福 | 来源:发表于2017-07-03 14:51 被阅读43次
$scope.data = [
    {
        str: 'a'
    },
    {
        str: 'b'
    },
    {
        str: 'c'
    }
]
//自定义指令repeatFinish
app.directive('repeatFinish',function(){
    return {
        link: function(scope,element,attr){
            console.log(scope.$index)
            if(scope.$last == true){
                console.log('ng-repeat执行完毕')
                scope.$eval( attr.repeatFinish );  // ng-repeat执行完毕后触发此函数
            }
        }
    }
});
$scope.renderFinish = function(){
    console.log('渲染完之后的操作')
}
<div id="box">
    <span ng-repeat="item in data" repeat-finish="renderFinish()">{{item.str}}</span>
</div>

相关文章

网友评论

      本文标题:检测ng-repeat finish

      本文链接:https://www.haomeiwen.com/subject/jtzacxtx.html