Angularjs ui-select 下拉菜单 on-select 函数调用问题
Angularjs ui-select dropdown on-select function call issue
在我的 AngularJS 项目中,我使用正常的 select 下拉菜单并使用 ng-change 进行函数调用,效果很好。现在我想将相同的下拉列表迁移到 ui-select。但是 on-select 函数调用不起作用,我尝试了不同的方法但没有成功。请找到我的 plnkr
下面是我用ui-select试过的两种方法:
<ui-select ng-model="uiSelectedCustomer" theme="select2" on-select="getDataBasedonCustomer(uiSelectedCustomer)" style="min-width: 300px;">
<ui-select-match placeholder="Select a customer..">{{$select.selected.name}}</ui-select-match>
<ui-select-choices repeat="cust in customers | filter: $select.search">
<div ng-bind-html="cust.name | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
<ui-select ng-model="uiSelectedCustomer" theme="select2" on-select="getDataBasedonCustomer(uiSelectedCustomer)" style="min-width: 300px;">
<match placeholder="Select a customer in the list or search his name ">{{$select.selected.name}}</match>
<choices repeat="cust in customers | filter: $select.search">
<div ng-bind-html="cust.name | highlight: $select.search"></div>
</choices>
</ui-select>
我从你的代码中了解到你想要选择项目并根据选择做一些事情,如果是这样的话,将 on-select="onSelected($item)"
添加到你的 ui-select
和控制器中:
$scope.onSelected = function (selectedItem) {
// do selectedItem.PropertyName like selectedItem.Name or selectedItem.Key
// whatever property your list has.
}
在我的 AngularJS 项目中,我使用正常的 select 下拉菜单并使用 ng-change 进行函数调用,效果很好。现在我想将相同的下拉列表迁移到 ui-select。但是 on-select 函数调用不起作用,我尝试了不同的方法但没有成功。请找到我的 plnkr
下面是我用ui-select试过的两种方法:
<ui-select ng-model="uiSelectedCustomer" theme="select2" on-select="getDataBasedonCustomer(uiSelectedCustomer)" style="min-width: 300px;">
<ui-select-match placeholder="Select a customer..">{{$select.selected.name}}</ui-select-match>
<ui-select-choices repeat="cust in customers | filter: $select.search">
<div ng-bind-html="cust.name | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
<ui-select ng-model="uiSelectedCustomer" theme="select2" on-select="getDataBasedonCustomer(uiSelectedCustomer)" style="min-width: 300px;">
<match placeholder="Select a customer in the list or search his name ">{{$select.selected.name}}</match>
<choices repeat="cust in customers | filter: $select.search">
<div ng-bind-html="cust.name | highlight: $select.search"></div>
</choices>
</ui-select>
我从你的代码中了解到你想要选择项目并根据选择做一些事情,如果是这样的话,将 on-select="onSelected($item)"
添加到你的 ui-select
和控制器中:
$scope.onSelected = function (selectedItem) {
// do selectedItem.PropertyName like selectedItem.Name or selectedItem.Key
// whatever property your list has.
}