0
我有以下問題。 在我的控制器我有這個變量:AngularJS不更新選定的選項
$scope.types = [
{id: 0, name: $translate.instant("FIRST")},
{id: 1, name: $translate.instant("SECOND")},
{id: 2, name: $translate.instant("THIRD")},
{id: 3, name: $translate.instant("FOURTH")}
];
$scope.itemtype = {};
$scope.itemtype = $scope.types[0];
在我看來,我有這樣的選擇
<select class="form-control"
required
ng-model="itemtype"
ng-options="item as item.name for item in types track by item.id">
</select>
我有工作完全類似的選擇,但是這是行不通的,如果我選擇第二在模型中選擇舊值仍然選中,但在資源管理器中,我正在查看第二個選項。
在Firebug我查看此輸出
<select class="form-control ng-pristine ng-valid ng-valid-required ng-touched" ng-options="item as item.name for item in types track by item.id" ng-model="itemtype" required="" tabindex="0" aria-required="false" aria-invalid="false">
<option value="0" label="First">First</option>
<option value="1" label="Second">Second</option>
<option value="2" label="Third"> Third </option>
<option value="3" selected="selected" label="Fourth"> Fourth </option>
</select>
我怎樣才能解決呢?
感謝