I have the following code that works fine as far as sorting by the desired property:
<select ng-model="sortorder">
<option value="name">Sort by Name</option>
<option value="created">Sort by Date</option>
</select>
<div ng-repeat="item in items | orderBy:sortorder">
{{item.name}}, {{item.created}}
</div>
However, the date comes in as a string, ex: April, 5 2016 which is not giving me accurate sorting. How can I detect if the list is being sorted by created
and then convert that to a Date
object to get accurate results.
Sample output:
sample name 1, April 6, 2016
sample name 2, January 13, 2014