AngularJS 不更新所选选项

AngularJS doesn't update selected option

我有以下问题。 在我的控制器中我有这个变量:

$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

            <select class="form-control" 
                    required
                    ng-model="itemtype"
                    ng-options="item as item.name for item in types track by item.id">
            </select>

我有类似的 selects 可以完美地工作,但这不起作用,如果我 select 模型中的第二个选项旧值仍然是 selected,但是在资源管理器中,我将第二个选项视为 selected.

在 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>

我该如何解决?

谢谢

您同时使用了 'select as' 和 'track by',但是 API 文档说:

Do not use select as and track by in the same expression. They are not designed to work together.

参考:

https://code.angularjs.org/1.3.10/docs/api/ng/directive/select

http://gurustop.net/blog/2014/01/28/common-problems-and-solutions-when-using-select-elements-with-angular-js-ng-options-initial-selection/