Components: autocomplete "(onItemSelected)"="do($event)"

Created on 13 Mar 2017  路  8Comments  路  Source: angular/components

Bug, feature request, or proposal:

feature request

What is the expected behavior?

@Output() event on item selected

What is the current behavior?

not @Output() event on item selected

What is the use-case or motivation for changing an existing behavior?

I'm currently using breeze client, that allows to update property from ngModel only.
In this case one way to update property to listen if autocomplete item selected

Which versions of Angular, Material, OS, browsers are affected?

"@angular": "~2.4.3",
"@angular/material": "^2.0.0-beta.2",

Most helpful comment

@rupinr
Instead of (onSelectionChange)="test($item)" use (onSelectionChange)="test(option)"

All 8 comments

md-option has onClose, it can be used as workaround

md-option has onSelect, is this what you want?

<md-autocomplete #appSearch="mdAutocomplete">
  <md-option *ngFor="let app of apps" [value]="app.name" (onSelect)="onAppSelect(app)">
    {{ app.name }}
  </md-option>
</md-autocomplete>

@chouclee Yes, i've used md-option's onClose, it'd be nice to see it it in examples somewhere!

As a note, the api changes from onSelect to onSelectionChange in #2722 to account for select/deselect of multiple options.

Guys onSelect method not exists.

I used onSelectionChange instead of onSelect.

[value]="option">
{{ option.viewValue }}

test(item){
console.log(item);
}.

But I only see undefined in console. Is there anything wrong here?

@rupinr
Instead of (onSelectionChange)="test($item)" use (onSelectionChange)="test(option)"

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings