{{$item["name"]}} I want to ca" /> {{$item["name"]}} I want to ca" /> {{$item["name"]}} I want to ca"/>

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

163 views Asked by At

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?

1

There are 1 answers

0
Khaled Aljundi On

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 () {...});