删除JSON对象的最后一个元素上的元素

时间:2014-01-09 09:35:19

标签: json angularjs

你如何有条件地从这个JSON对象的输入中删除最后一个<“hr>从而检索其中的最后一个对象?

  <div class="row" ng-repeat="post in posts">
    <div class="col-lg-9 col-lg-offset-2">        
      <!-- blog entry -->
      <h1><a href="#">{{post.title}} </a></h1>
      <p><span class="glyphicon glyphicon-time"></span>{{post.time_Date}} </p>
      <img ng-src="{{post.imageUrl}}" width="400" height="350">
      <br>
      <br>
      <br>
      <p>{{post.blog_Post}} </p>
      <a class="btn btn-default btn-sm" href="#">Read More <span class="glyphicon glyphicon-chevron-right"></span></a>      
      <hr>
    </div>
  </div>

1 个答案:

答案 0 :(得分:1)

<div class="row" ng-repeat="post in posts">
    <div class="col-lg-9 col-lg-offset-2">        
      <!-- blog entry -->
      <h1><a href="#">{{post.title}} </a></h1>
      <p><span class="glyphicon glyphicon-time"></span>{{post.time_Date}} </p>
      <img ng-src="{{post.imageUrl}}" width="400" height="350">
      <br>
      <br>
      <br>
      <p>{{post.blog_Post}} </p>
      <a class="btn btn-default btn-sm" href="#">Read More <span class="glyphicon glyphicon-chevron-right"></span></a>      
      **<hr ng-hide="$index==posts.length">**
    </div>
  </div>

这样的事情应该有效