Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove <hr/> for last li in angular ng-repeat

Here is my angular View

<li class= "riskmanagementlink" ng-repeat="link in links">
  <h3> {{link.Description}}   </h3> 
  <a> {{link.Title}} </a>
  <hr/>
</li>

I would like to remove the hr tag for the last list item. Can anybody help me do this please?

like image 550
Aj1 Avatar asked Sep 24 '14 17:09

Aj1


1 Answers

The ng-repeat directive comes with some extra properties like $last, which indicates that you're on the last item of your collection.

<li class="riskmanagementlink" ng-repeat="link in links">
  <h3> {{ link.Description }} </h3> 
  <a> {{ link.Title }} </a>
  <hr ng-if="!$last" />
</li>

More info in the docs.

like image 143
Preview Avatar answered Nov 14 '22 23:11

Preview