0

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>
seasick
  • 1,094
  • 2
  • 15
  • 29
  • You could apply a class to it through the model, e.g. `
    ` and then set hrHidden to a class that either hides or shows the hr. Not really fitting with what a model is, but would work. Edit: this may also help you: http://stackoverflow.com/questions/14077471/conditional-logic-in-angularjs-template
    – MasNotsram Jan 09 '14 at 09:38
  • Can you post an example of this possibly? – seasick Jan 09 '14 at 10:02

1 Answers1

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>

Something like this should work

Ayobami Opeyemi
  • 752
  • 7
  • 13