Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them, it only takes a minute:

i have an string array in angularJS and i want to do some kind of sort for it's element i try this code but it isn't work and i don't know why any one has any 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>
share|improve this question

1 Answer 1

up vote 5 down vote accepted

You can use a function in the orderBy-clause like this:

<li data-ng-repeat="country in countries | filter:name | orderBy:'toString()'"> {{ country }}</li>
share|improve this answer
    
orderBy without any addition attribute will work fine – Ahmad Alyan Jun 13 '13 at 7:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.