I have this dropdownlist in my template:
我在我的模板中有这个下拉列表:
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5">
<div class="input-group input-group-sm">
<select class="form-control"
data-ng-options="o.name for o in list.itemsStatus"
data-ng-model="list.currentItemsStatus"
ng-change="list.getItems(o.id)">
</select>
</div>
</div>
Here is how is defined itemsStatus in controller:
以下是控制器中如何定义itemsStatus:
this.itemsStatus = [{ name: "all", id: 1 }, { name: "new", id: 2 }, { name: "toUpdate", id: 3 }];
when new item is selected I fire this function:
当选择新项目时,我启动此功能:
function getItems(status) {
switch (status) {
case 1:
break;
case 2:
break;
case 3:
break;
default:
}
}
But passed parameter- status
is always undefined.
但是传递的参数状态总是未定义的。
How can I pass to getItems() event the selected item as parameter?
如何将所选项作为参数传递给getItems()事件?
1 个解决方案
#1
2
ng-change
event can't pass ng-options
current item as value.
ng-change事件无法将ng-options当前项目作为值传递。
You already do have selected value inside your ng-model
, so you can pass your model which already has o
(current selected value)
您已经在ng-model中选择了值,因此您可以传递已经具有o(当前选定值)的模型
ng-change="list.getItems(list.currentItemsStatus.id)"
#1
2
ng-change
event can't pass ng-options
current item as value.
ng-change事件无法将ng-options当前项目作为值传递。
You already do have selected value inside your ng-model
, so you can pass your model which already has o
(current selected value)
您已经在ng-model中选择了值,因此您可以传递已经具有o(当前选定值)的模型
ng-change="list.getItems(list.currentItemsStatus.id)"