R3tep
R3tep

Reputation: 12864

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

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!

Upvotes: 5

Views: 2266

Answers (2)

PrimosK
PrimosK

Reputation: 13918

I think this should work:

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

There you have working JSFiddle.

Upvotes: 6

Zack Argyle
Zack Argyle

Reputation: 8407

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

Upvotes: 2

Related Questions