M
M
Max2015-05-20 15:13:02
Angular
Max, 2015-05-20 15:13:02

How to implement sorting in Angular?

Hello, please tell me how to sort from the dropdown list. This list includes countries producing goods.

<select ng-model="model.country">
                    <option value="Украина">Zero</option>
                    <option value="Беларусь">One</option>
                    <option value="Россия">Two</option>
                  </select>

Before that, I did sorting with radio buttons and by name like this:
<div class="product_ramka" ng-repeat="product in products| filter:enterName |orderBy:'price':reverse">

The text itself is displayed like this:
<p>Страна: {{product.country}}</p>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Osher, 2015-05-20
@miraage

https://docs.angularjs.org/api/ng/filter/orderBy
In your case, reverse will be looked up in the scope context.
Either write orderBy:'price':true or declare $scope.reverse = true.
// UPD
In your case, I would have a filter function. More details on google.
stackoverflow.com/questions/26400113/angularjs-dyn...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question