我有以下问题。在我的控制器中,我有这个变量:
$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>
我有类似的选择可以完美地工作,但这不起作用,如果我在模型中选择第二个选项,旧值仍然处于选中状态,但在资源管理器中,我将第二个选项视为已选中。
在萤火虫中,我正在查看此输出
<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>
我该如何解决?
谢谢