I have the following HTML code
<select name="Gender" class="form-control">
<option value="m">Male</option>
<option value="f">Female</option>
</select>
I want to change the select parameter on click using AngularJs. I have tried almost everything and I understand that the problem occurs when the click event is called, if there is no click event it works fine
HTML:
<body ng-app ng-controller="AppCtrl">
<div ng-click="setGender()">Set</div>
<select name="Gender" class="form-control">
<option value="m" ng-selected="{{GenderInfo.Gender =='m'}}">Male</option>
<option value="f" ng-selected="{{GenderInfo.Gender =='f'}}">Female</option>
</select>
</body>
AngularJs:
function AppCtrl($scope) {
$scope.setGender = function(){
$scope.GenderInfo = {
Gender: 'f'
}
}
}
JsFiddle:
http://jsfiddle.net/dCFd2/231/
source
to share