AngularJS ngRepeat orderBy not working with DateTime string

See this JSFiddle http://jsfiddle.net/luke88jones/MfLqa/2/

<div ng-repeat="booking in testBookings | orderBy: 'booking.sortDate'">
      <span>{{booking.bookingDateTime | date:'dd-MMM-yy HH:mm'}}</span>      
</div>

I am trying to use orderBy to sort ng-repeat. Our data currently uses the bookingDateTime method for a filter that does not work. I was not sure that angular does not solve this function, so I added the sortDate property as an ISO string and tried to sort it, but it doesn't seem to work.

Any ideas?

+4
source share
1 answer

Try this instead:

<div ng-repeat="booking in testBookings | orderBy:'sortDate'">

working fiddle: http://jsfiddle.net/Bq7hb/

+6
source

Source: https://habr.com/ru/post/1532458/


All Articles