seasick
seasick

Reputation: 1225

remove element on last element of JSON object

How would you conditionally remove the last <"hr> from the input of this JSON object..upon retrieving the last object inside of it?

  <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>

Upvotes: 0

Views: 389

Answers (1)

Ayobami Opeyemi
Ayobami Opeyemi

Reputation: 752

<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>

Something like this should work

Upvotes: 1

Related Questions