最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to call a scope inside a ng-repeat just for the last element? - Stack Overflow

programmeradmin3浏览0评论

I want to call a scope function inside my ng-repeat just for the last element, like this:

<div ng-repeat="patient in patients" >
  <div ng-if="$last" ng-load="myFunction()"></div>
</div>

But ng-load doesn't work!

I want to call a scope function inside my ng-repeat just for the last element, like this:

<div ng-repeat="patient in patients" >
  <div ng-if="$last" ng-load="myFunction()"></div>
</div>

But ng-load doesn't work!

Share Improve this question edited Apr 2, 2015 at 13:40 R3tep asked Mar 3, 2014 at 16:45 R3tepR3tep 12.9k10 gold badges51 silver badges76 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 6

I think this should work:

  <div ng-repeat="element in array" ng-init="$last && myFunction(element)">
       {{element}}          
  </div>

There you have working JSFiddle.

Use ng-init="$last && myFunction()", that should do the same thing.

发布评论

评论列表(0)

  1. 暂无评论