1

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> 

2 Answers 2

4

Apply orderBy filter on that field. You can learn more here about sorting.

ng-repeat="damageResult in damageResultList | orderBy:'YOUR_FIELD_NAME'"
Sign up to request clarification or add additional context in comments.

Comments

1

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 ">

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.