将 Select 选项绑定到模型 AngularJS

Binding Select Option to Model AngularJS

调试后,状态对象似乎已绑定到我的模型。但我需要将字符串绑定到我的模型。

$scope.Statuses = [
    {name:'Not Started', value: 'Not Started'},
    {name:'In Progress', value: 'In Progress'},
    {name:'Completed', value: 'Completed'}
];

<select class="form-control" ng-model="counterMeasure.Status" ng-options="status.name for status in Statuses"></select>

您需要使用以下 ngOptions 语法

select as label for value in array

将您的代码更改为

ng-options="status.value as status.name for status in Statuses"