-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
feat(autocomplete): fire "onSelected" event when the user select an option #3645
Comments
There is an /** Stream of autocomplete option selections. */
get optionSelections(): Observable<MdOptionSelectionChange> {
return Observable.merge(...this.autocomplete.options.map(option => option.onSelectionChange));
} |
I haven't tested, but I think that this observer would work for what I'm needing. But the point is that it'll be nicer if we can just create a listener on our class and use the event listener right from the html page.
|
Great! I can use that for now. Thanks @willshowell |
@kara do you think that "onSelected" will be a good name for the output event? If so, I can create a PR with this change |
Just came across this randomly, and wanted to mentioned that the official styleguide discourages the "on-" prefix for output events. |
Emits the `select` event when an option in the autocomplete is selected. **Note:** I went with passing the selected option from the trigger to the panel, instead of listening to the `onSelectionChange` inside the panel, because it involves keeping track of less subscriptions and not having to re-construct them when the list of options changes. Fixes angular#4094. Fixes angular#3645.
+1 |
Emits the `select` event when an option in the autocomplete is selected. **Note:** I went with passing the selected option from the trigger to the panel, instead of listening to the `onSelectionChange` inside the panel, because it involves keeping track of less subscriptions and not having to re-construct them when the list of options changes. Fixes angular#4094. Fixes angular#3645.
Emits the `select` event when an option in the autocomplete is selected. **Note:** I went with passing the selected option from the trigger to the panel, instead of listening to the `onSelectionChange` inside the panel, because it involves keeping track of less subscriptions and not having to re-construct them when the list of options changes. Fixes angular#4094. Fixes angular#3645.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug, feature request, or proposal:
featur
What is the expected behavior?
Create a new output (onSelected?) that fires an event when the user select an option from the autocomplete
What is the current behavior?
There is no way to know when the user has selected an option from the autocomplete
What is the use-case or motivation for changing an existing behavior?
I have some cases that I need to update some fields based on the user selected option and would be nice if I can get a callback from the component itself
The text was updated successfully, but these errors were encountered: