How to make orderby with angularJS for a string array, not an array of objects

I have a string array in angularJS and I want to make some kind of view for this element. I try this code, but it does not work, and I do not know why anyone has an idea.

<div id="cpntainer" data-ng-init="countries = ['Syria','Lebanon','Jordon','Egypt']"> Country Name <br /> <input type="text" data-ng-model="name" /> <br /> <ul> <li data-ng-repeat="country in countries | filter:name | orderBy:country:false "> {{ country }} </li> </ul> </div> 
+4
source share
1 answer

You can use the function in orderBy position:

 <li data-ng-repeat="country in countries | filter:name | orderBy:'toString()'"> {{ country }}</li> 
+7
source

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


All Articles