Sihem Hcine
Sihem Hcine

Reputation: 1129

orderBy doesn't work with ng-repeat

Am using orderBy to sort my objects by their startdate.

<ion-list>
<ion-item  ng-repeat="e in events | orderBy: e.startdate">
 <h4>{{e.name}}</h4>
 <h4>{{e.startdate}}</h4>
</ion-item>
</ion-list>

But it doen't work , how can i fix it please

Upvotes: 1

Views: 42

Answers (2)

Rikin
Rikin

Reputation: 5473

<ion-item ng-repeat="e in events | orderBy: startdate"> Because each ng-repeat has its own scope and you are already in the scope of e when orderBy evaluates.

Upvotes: 2

Yin Gang
Yin Gang

Reputation: 1443

By this:

<ion-list>
<ion-item  ng-repeat="e in events | orderBy: 'startdate'">
 <h4>{{e.name}}</h4>
 <h4>{{e.startdate}}</h4>
</ion-item>
</ion-list>

Upvotes: 3

Related Questions