ng-model 不会在 IE 中更新
ng-model does not get updated in IE
下面的代码设置了 ng-model JUST ONCE ,而在 CHROME 和 FF 中它工作正常。
<form>
<div ng-repeat="ques in $.vm.records track by $index">
<div class="input-group">
<select ng-model="ques.choiceid">
<option value=""></option>
<option value="{{choice.id}}" ng-repeat="choice in ques.choices track by $index" >{{ choice.text }}</option>
</select>
</div>
</div>
</form>
更新
我使用的是angular版本1.4.7,浏览器版本是IE11
尝试将 ng-options
用于 angular 中的 select 下拉列表,如 angular 文档中所示。
以下代码在 IE 中有效。
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"> </script>
</head>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<select ng-options="item as item.label for item in items track by item.id" ng-model="selected"></select>
<div class="">
Selected id : {{selected.id}} and value : {{selected.label}}
</div>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.items = [{
id: 1,
label: 'aLabel',
subItem: { name: 'aSubItem' }
}, {
id: 2,
label: 'bLabel',
subItem: { name: 'bSubItem' }
}];
});
</script>
</body>
</html>
下面的代码设置了 ng-model JUST ONCE ,而在 CHROME 和 FF 中它工作正常。
<form>
<div ng-repeat="ques in $.vm.records track by $index">
<div class="input-group">
<select ng-model="ques.choiceid">
<option value=""></option>
<option value="{{choice.id}}" ng-repeat="choice in ques.choices track by $index" >{{ choice.text }}</option>
</select>
</div>
</div>
</form>
更新 我使用的是angular版本1.4.7,浏览器版本是IE11
尝试将 ng-options
用于 angular 中的 select 下拉列表,如 angular 文档中所示。
以下代码在 IE 中有效。
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"> </script>
</head>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<select ng-options="item as item.label for item in items track by item.id" ng-model="selected"></select>
<div class="">
Selected id : {{selected.id}} and value : {{selected.label}}
</div>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.items = [{
id: 1,
label: 'aLabel',
subItem: { name: 'aSubItem' }
}, {
id: 2,
label: 'bLabel',
subItem: { name: 'bSubItem' }
}];
});
</script>
</body>
</html>