Tupu Sipaia Kikhteva
Tupu Sipaia Kikhteva

Reputation: 53

How to handle item select in AngularJS Autocomplete

I am very new to AngularJS..

I managed to implement Autocomplete control by using example

https://material.angularjs.org/latest/demo/autocomplete

Unfortunately it is only part of my control. And now I have tried everything but I can't get how to handle the event when an item get selected.

I am trying to implement multiple selects one depending on selected value of another.

Thanks!

Upvotes: 0

Views: 2391

Answers (1)

Fetrarij
Fetrarij

Reputation: 7326

You can use md-selected-item-change attribute

md-selected-item-change expression An expression to be run each time a new item is selected

eg:

<md-autocomplete
          ...
          md-selected-item-change="selectedItemChange(item)">
</md-autocomplete>

js:

$scope.selectedItemChange = function(item) {
  $log.info('Item changed to ' + JSON.stringify(item));
}

Upvotes: 1

Related Questions