Angular不会使用ng模型的内容更新选择元素。绑定是单一方式select-> model。如何在传播到视图的模型中进行更改?角度不会使用ng模型更新选择元素
模板:
<select class="gu2" name="coverDuration" ng-model="creditLimit.coverDuration" required="required">
<option ng-value="90" selected="selected">90 days</option>
<option ng-value="180">180 days</option>
</select>
just to check: {{creditLimit.coverDuration}}
控制器:
app.controller('CreditLimitDetailsController', function ($scope, creditLimit /* ... */) {
// creditLimit.coverDuration can be 90 or 180.
// I use a service to store the values between successive instanciations
$scope.creditLimit = creditLimit;
}
在本例中,选择住宿没有选项选择,而检查显示90
看看[ngOptions](http://docs.angularjs.org/api/ng.directive:select) 。这可能会让事情变得更容易。 – Mouagip
我看到了很多与ngOptions的答案,但这似乎矫枉过正,只有两个静态选项:/。严重的是,这样一个简单的东西怎么能不被包含在角? – BiAiB