简体   繁体   中英

angular ui-select: calling a function with one of the items selected

I have a ui-select element with:

<ui-select-match style="width: 100%;" placeholder="Select values...">{{$item["name"]}}</ui-select-match>

I want to call a function when user clicks on any one of the selected item(there can be multiple items selected). So the invoked function would only receive the item clicked.

<ui-select-match ng-click="$ctrl.myFunction($item["name"])" style="width: 100%;" placeholder="Select values...">{{$item["name"]}}</ui-select-match>

But it is not working. myFunction receives undefined value. What is correct way of getting hold of selected item?

Why don't you watch the value of the model that gets updated

<ui-select ng-model="model.example">

in Js

$scope.$watch('model.example', function () {...});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM