1

I have 2 questions in 1 post: I would like to limit the number of result with 10 results and I would like to sort post by date but it's not working because it sort by user then by date and I would like to sort by date no matter the user.

Here what i tried:

<ul ng-repeat="item in customarray  | orderBy:'-tickets[0].date' | limitTo : 10 track by $index">
    <div  ng-repeat="new in item.tickets   track by $index ">
        <li class="row"><div class="col-md-2 date text-center">{{new.date | date}}</div><div class="col-md-3 date text-center"> {{item.username}}</div> <div class="col-md-5 date text-center">{{new.titre}}</div> <div class="col-md-2 date text-center">{{new.status}}</div></li>
    </div>
</ul>

The problem is that my data is contain in 2 ng-repeat.

Mika
  • 5,807
  • 6
  • 38
  • 83
moskitos
  • 149
  • 1
  • 2
  • 13
  • 1
    I think it should be `ng-repeat="item in customarray track by $index | orderBy:'-tickets[0].date' | limitTo : 10"` or `ng-repeat="item in customarray | orderBy:'-tickets[0].date' | limitTo : 10"` No need to add track by $index because it will automatically track by $index – Rakesh Chand May 10 '16 at 13:05

1 Answers1

0

I think it should be

ng-repeat="item in customarray track by $index | orderBy:'-tickets[0].date' | limitTo : 10"

or

ng-repeat="item in customarray | orderBy:'-tickets[0].date' | limitTo : 10"

No need to add track by $index because it will automatically track by $index

Rakesh Chand
  • 3,105
  • 1
  • 20
  • 41