4

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

1 Answer 1

8

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

<li data-ng-repeat="country in countries | filter:name | orderBy:'toString()'"> {{ country }}</li>
Sign up to request clarification or add additional context in comments.

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.