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

javascript - How to remove <hr> for last li in angular ng-repeat - Stack Overflow

programmeradmin0浏览0评论

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?

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?

Share Improve this question edited Feb 2, 2017 at 18:02 Preview 35.8k10 gold badges95 silver badges113 bronze badges asked Sep 24, 2014 at 17:35 Aj1Aj1 9732 gold badges16 silver badges42 bronze badges 1
  • 2 <hr ng-if="!$last"/> $last will tell you if it is the last item repeated – PSL Commented Sep 24, 2014 at 17:37
Add a ment  | 

1 Answer 1

Reset to default 11

The ng-repeat directive es 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.

发布评论

评论列表(0)

  1. 暂无评论