$index not working properly with OrderBy

68 views Asked by At
<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.

1

There are 1 answers

0
RIYAJ KHAN On

Store it first

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

then

$index + len

In html.