0
<div ng-repeat="msg in currDateByMsg[msgDate.strDate]|orderBy :'-SendMsgDate':true">
     <div ng-if="!msg.currentUser">
       <div data-ng-if="$first || (currtDateByMsg[msgDate.strDate][$index].userId !=
         currDateByMsg[msgDate.strDate][$index -1].userId)">
         <img class="img-circle" ng-src="{{msg.iconPath}}"/> 
       </div>
     </div>
     <div>{{msg.userMessage}}</div>
</div>

i want to skip images when more than on message come from same user(i.e- show only one image).I'm iterating in reverse order but $index value is taking from 0. so how i reverse the index value too.

Manel
  • 176
  • 4
  • 16
Omprakash Sharma
  • 409
  • 5
  • 11
  • $index is an iterator offset of the repeated element (0..length-1), it will be always start from 0, order by will reverse the data by SendMsgDate. so at $index = 0 you will get the last item. – Deep Dec 19 '16 at 14:07
  • Check [this question](http://stackoverflow.com/questions/16118762/angularjs-wrong-index-after-orderby) out, the answer by mile should help you solve your issue – George Dec 19 '16 at 14:08

1 Answers1

0

Store it first

var len = (currDateByMsg[msgDate.strDate].length-1);

then

$index + len

In html.

RIYAJ KHAN
  • 15,032
  • 5
  • 31
  • 53