Change the selected <parameter> <select> using ng-click

I am wondering how I can change selected <option>from <select>using ng-click.

            <select ng-model="orderProp">
                <option value="name">Alphabetical</option>
                <option value="age">Newest</option>
            </select>

            <a href="" ng-click="orderProp=name">order</a>

Can this be done, as in the above example?

THX

+4
source share
2 answers

There are two ways to do this: either call the function when the anchor is clicked, or simply set the value 'name'as a string.

1) http://jsfiddle.net/HB7LU/10717/ here you can directly set the line 'name'to ng-click

2) Or this, http://jsfiddle.net/HB7LU/10718/

 <a href="" ng-click="fun()">order</a>
 $scope.fun=function(){
         $scope.orderProp= 'name'
    }
+1

, , . , , . , , , "" .

<select ng-model="orderProp">
    <option value="name">Alphabetical</option>
    <option value="age">Newest</option>
</select>

<a href="" ng-click="orderProp='name'">order</a>
+3

All Articles