Reputation: 21
Here is my scenario
<selectclass="form-control" id="my_select"><optionvalue="0">List is Number</option><option value="1">List is Alphabetical</option></select>
<liclass="ui-state-default " ng-repeat="damageResult in damageResultList> <span>{{damageResult.damageMechanismList}}hfgh</span></li>
Upvotes: 1
Views: 998
Reputation: 18065
what you can do is define a custom function to sort and convert the text to number in case field is number
$scope.sorterFunc = function(entity){
return $scope.isFieldNumber? parseInt(entity[$scope.property], 10) : entity[$scope.property];
};
and then in ng-repeat
<div ng-repeat="entity in entityArray | orderBy:sorterFunc ">
Upvotes: 1
Reputation: 4274
Apply orderBy
filter on that field. You can learn more here about sorting.
ng-repeat="damageResult in damageResultList | orderBy:'YOUR_FIELD_NAME'"
Upvotes: 4