javascript - How to pass the chosen dropdown value to ng-repeat orderby -


i have created normal dropdown box.in need pass selected value ng-repeat orderby filtration.

this dropdown

<select   name='filter_range' id='filter_range'   onchange='filter()'>     <option value='mrplow'> mrp low high</option>     <option value='mrphigh'> mrp high low </option>     <option value='qtyhigh'> qty low high </option>     <option value='qtylow'> qty high low </option> </select> 

angular js

<div  ng-app="myapp" ng-controller="mycontroller">      <div  ng-repeat = "grp_val in sample | orderby:'mrplow'"         <label>{{grp_val.product}}</label><br>     </div> </div> 

now how can pass selected value ng-repeat orderby:' '?

i example same problem here:

    angular.module('orderbyexample', [])        .controller('examplecontroller', ['$scope',          function($scope) {            $scope.friends = [{              name: 'john',              phone: '555-1212',              age: 10            }, {              name: 'mary',              phone: '555-9876',              age: 19            }, {              name: 'mike',              phone: '555-4321',              age: 21            }, {              name: 'adam',              phone: '555-5678',              age: 35            }, {              name: 'julie',              phone: '555-8765',              age: 29            }];            $scope.predicates = ['name', 'phone', 'age'];            $scope.predicate = 'name';          }        ]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>  <div ng-app="orderbyexample" ng-controller="examplecontroller">    <select ng-model="predicate" ng-options="p p p in predicates"></select>    <table class="friend">      <tr>        <th>name</th>        <th>phone number</th>        <th>age</th>      </tr>      <tr ng-repeat="friend in friends | orderby:predicate">        <td>{{friend.name}}</td>        <td>{{friend.phone}}</td>        <td>{{friend.age}}</td>      </tr>    </table>  </div>

please refer here: https://docs.angularjs.org/api/ng/filter/orderby

hope help.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -