Skip to content

md-autocomplete optionsSelection #3280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ambarkiy opened this issue Feb 24, 2017 · 5 comments
Closed

md-autocomplete optionsSelection #3280

ambarkiy opened this issue Feb 24, 2017 · 5 comments

Comments

@ambarkiy
Copy link

What is the expected behavior?

I want to call a function when an option is selected. After some search it seem that i have to use :

property optionSelections of MdAutocompleteTrigger

In the documentation : https://material.angular.io/components/component/autocomplete optionSelections Stream of autocomplete option selections.

I dont understand that , what is a stream, how to implement this ?

What is the current behavior?

Iam able to have MdAutocompleteTrigger In my component i add : @ViewChild(MdAutocompleteTrigger) trigger:MdAutocompleteTrigger; ngAfterContentInit() { setTimeout(() =>this.trigger.openPanel()); } but i cannot use optionSelections, can someone can give me an example

I try this ngAfterContentInit() { setTimeout(() => Observable.merge(...this.trigger.optionSelections) .subscribe((option)=>console.log(option))); } but not working

Is there anything else we should know?

@kara
Copy link
Contributor

kara commented Feb 24, 2017

Please keep GitHub issues for bug reports / feature requests. Better avenues for troubleshooting / questions are stack overflow, gitter, mailing list, etc.

Here is a plunker example though: https://plnkr.co/edit/AaBESvqvT40htQPlAp0b?p=preview. In the next release, you shouldn't have to merge the selection events yourself, see #3212

@kara kara closed this as completed Feb 24, 2017
@ambarkiy
Copy link
Author

Thank you sorry

@ktersius
Copy link

ktersius commented Mar 29, 2017

@kara The sample you provided only fires the option selected "event" once. If you change the text and select another option the new option event is not fired. Any ideas?

Another option is to use the option onSelect #3576

@ambarkiy
Copy link
Author

thank you 're write

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants