I am wondering how I can change selected <option>from <select>using ng-click.
<option>
<select>
<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
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.
'name'
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' }
, , . , , . , , , "" .
<select ng-model="orderProp"> <option value="name">Alphabetical</option> <option value="age">Newest</option> </select> <a href="" ng-click="orderProp='name'">order</a>