Mandroid
Mandroid

Reputation: 7468

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?

Upvotes: 0

Views: 181

Answers (1)

Khaled Aljundi
Khaled Aljundi

Reputation: 1

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

Upvotes: 0

Related Questions