angular 获取ng-repeat完成状态 $last


$index $first $middle $last $odd $even

html

<ul>
    <li ng-repeat="item in data" repeat-finish="renderFinish()">{{item.str}}</li>
</ul>

指令

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 )
            }
        }
    }
})

ctrl里面

//controller里对应的处理函数
$scope.renderFinish = function(){
    console.log('渲染完之后的操作')
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM