below my dropdown is working fine in firefox, chrome. but in Internet explore while selecting the 2 value , dropdown box (first time) selected first value only , Thanks in advance
for ref check below link in IE :
http://jsfiddle.net/ExpertSystem/fDdwe/
var app = angular.module('myApp', []);
app.controller('myCtrl', function ($scope) {
$scope.users = [
{id: 1, name: 'Me'},
{id: 2, name: 'You'}
];
});
app.directive('select', function () {
return {
restrict: 'E',
require: '?ngModel',
priority: 10,
link: function postLink(scope, elem, attrs, ctrl) {
if (!ctrl) { return; }
var originalRender = ctrl.$render.bind(ctrl);
ctrl.$render = function () {
originalRender();
if (elem.val() === '?') {
ctrl.$setViewValue(undefined);
}
};
}
};
});
.error {
color: Red;
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl" ng-form="form1">
<select name="select1"
ng-model="userId"
ng-options="user.id as user.name for user in users"
ng-init="userId=3"
required>
</select>
<div class="error" ng-show="form1.select1.$invalid">Required field !</div>
<div class="error" ng-show="form1.$invalid">Invalid form !</div>
<br />
<button ng-click="userId=1;">Set valid value</button>
<button ng-click="userId=3;">Set invalid value</button>
<hr />
<hr />
<pre>userId: {{userId}}</pre>
</div>