码迷,mamicode.com
首页 > Web开发 > 详细

AngularJs中,如何在ng-repeat完成之后,执行Js脚本

时间:2015-12-17 22:21:25      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:

  //ng-repeat生成4个li,生成后再执行自定义方法fn在每个li后加一根横线
<script> var myapp=angular.module(‘myapp‘,[]); myapp.directive(‘onFinishRenderFilters‘, function ($timeout) { return { restrict: ‘A‘, link: function(scope, element, attr) { if (scope.$last === true) { $timeout(function() { scope.$emit(‘ngRepeatFinished‘);//注册一个事件 }); } } }; }).controller(‘test‘,function($scope){ $scope.fn=function(){ $(‘.item‘).append(‘<hr/>‘) } $scope.$on(‘ngRepeatFinished‘, function (ngRepeatFinishedEvent) {//监听事件 //下面是在li render完成后执行的js $scope.fn() </script> <body ng-app="myapp" ng-controller="test"> <ul class="list" ng-init="aa=[1,2,3,4]"> <li class="item" ng-repeat="x in aa" on-finish-render-filters> hello world! </li> <ul> </body>

  

AngularJs中,如何在ng-repeat完成之后,执行Js脚本

标签:

原文地址:http://www.cnblogs.com/leyi/p/5055320.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!