我在页面中添加了2个选择框,如下所示
<div layout>
<md-input-container>
<label>Gender</label>
<md-select ng-model="selectedUser">
<md-option ng-value="user" ng-repeat="user in users">{{ user.sex }}</md-option>
</md-select>
</md-input-container>
</div>
<div layout>
<md-input-container>
<label>Location</label>
<md-select ng-model="selectedLocation">
<md-option ng-value="location" ng-repeat="loca in locations">{{ loca.location }}</md-option>
</md-select>
</md-input-container>
</div>
js就像这样
angular
.module('selectionApp', ['ngMaterial'])
.controller('sliderCtrl', sliderCtrl);
function sliderCtrl ($scope) {
$scope.users = [
{ id: 1, sex: 'Male' },
{ id: 2, sex: 'Female' }
];
$scope.locations = [
{ id: 1, location: 'A' },
{ id: 2, location: 'B' },
{ id: 3, location: 'C' }
];
}
正确加载性别选择框,第二个选择框加载选项,但我无法选择特定选项。每次重新加载时都选择“C”选项。我想知道如何解决这个问题。
任何帮助都非常感谢。 谢谢,
答案 0 :(得分:2)
将ng-value =“location”更改为ng-value =“loca”
你的问题可能会解决......
祝你好运..