I have an ng-repeat loop returning a list of objects which represent calendar events. I'd like to be able to orderBy date but it looks like first I need to push the returned objects into a single array.
Here is my angular view:
<div class="calendar">
<p>{{cal}}</p>
<div ng-repeat="items in cal">
<a href="/events/{{items.day}}">
<article class="eventslist">
<div class="numberedDate">
<h3>{{items.day}}</h3>
</div>
<div class="calInfo">
<h5>{{items.title}}</h5>
<p>{{items}} <a>more</a></p>
</div>
</article>
</div><!-- ng-repeat items -->
</div><!-- calendar -->
items is currently returning:
{"day":"21","title":"ok","summary":"ok","description":"ok","_id":"53ee9f0fc6aed109c6d33cfd"}
{"day":"2","title":"ok","summary":"ok","description":"ok","_id":"53ee9f038782309c6d892"}
{"day":"27","title":"ok","summary":"ok","description":"ok","_id":"533240fc6ae32433chd"}
Is there a way to wrap these returned objects into an array [] so that they could have an orderBy 'day' called on them?
items
is already an array,ng-repeat
would not work otherwise.orderby:day
on it should work, but you need to cast the value to Integer to get expected order. – Sergiu Paraschiv Aug 19 at 14:03