javascript - Using ng-if to select second item in an ng-repeat loop -


i'm working on page loops through bunch of content , orders/groups them out day. grouping works, want treat first 2 items in loop differently rest of them. i've tried utilizing ng-if in code example below using ng-if="$first || $index == 1" , ng-if="!$first || !$index != 1" doesn't seem doing trick.

what proper way select first , second items in ng-repeat loop?

<div class="col-sm-12 day-block" ng-repeat="(key,value) in article.items | groupby:'posted|date: mmm:dd' | toarray:true ">   <div class="col-sm-2 timestamp">     <h3>march 9</h3>     <h1>day 4</h1>   </div>   <div class="col-sm-10" ng-repeat="article in value | orderby:'posted' | unique: 'nid'">       <div class="col-sm-12">         <div class="row">           <div class="col-xs-6" ng-if="$first || $index == 1">             <span ng-class="blog-post-thumbnail" ng-bind-html="to_trusted(article.main_image)"></span>             <h2 ng-bind-html="to_trusted(article.node_title)"></h2>             <h4 ng-bind-html="to_trusted(article.author)"></h4>             <h4 ng-bind-html="to_trusted(article.posted)"></h4>           </div>         </div>        <div class="row" ng-if="!$first || $index != 1">         <div class="col-xs-4">           <span ng-class="blog-post-thumbnail" ng-bind-html="to_trusted(article.main_image)"></span>         </div>          <div class="col-xs-8">           <h3 ng-bind-html="to_trusted(article.node_title)"></h3>           <h4 ng-bind-html="to_trusted(article.author)"></h4>         </div>       </div>     </div>   </div> </div> 

your expression ng-if="!$first || !$index == 1 true index other 1. in order select 1st , 2nd can try: ng-if="$index == 0 || $index == 1"

for others can try ng-if="!($index == 0 || $index == 1)"


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -