我有2个select语句,第一个选择由我的第一个webservice请求填充。用户在第一个选择中选择所需的数据,其中将触发onChange方法来检索第一个选择对象,再次运行webservice以检索另一组数据并填充第二个select语句。无法填充第二个选择语句
HTML:
<div class="input-label">
Select Kittens:
</div>
<select
ng-model ="options"
ng-options ="option.name for option in options"
ng-change="onChange(options)">
<option>--</option>
</select>
<br>
<div class="input-label">
Select Age:
</div>
<select
ng-options ="detail.age for detail in details">
<option>--</option>
</select>
控制器:
.controller("ctrl",['$scope',function($scope){
$scope.options = [
{id:1, name:'typeA'},
{id:2, name:'typeB'},
{id:3, name:'typeC'},
{id:4, name:'typeD'}
]
$scope.onChange = function(item){
console.log("Hi world!");
console.log(item);
$scope.details = [
{id:1, age:'11'},
{id:2, age:'10'},
{id:3, age:'9'},
{id:4, age:'6'}
]
};
}])
问题:
1)选择所述第一选择后,该值只是从选择框消失,但该值(对象)成功传递到onChange函数
2)无法填充第二个选择框
我创建了一个plunkr来复制我的问题(没有web服务)。谢谢!
链接: http://plnkr.co/edit/tqI0a83PiIHNUkKLj1WF?p=preview
与我的相同:D –