You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(autocomplete): fire "onSelected" event when the user select an option #3645
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentfeatureLabel used to distinguish feature request from other issues
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
Reacted by Michael McCoy, Kim Kern, Daniel Haupt, Julien, chriswesterhuis, Jakub Krupka and Michael Prentice
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.
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentfeatureLabel used to distinguish feature request from other issues
Activity
willshowell commentedon Mar 17, 2017
There is an
optionSelectionsObservable on the autocomplete component. Does that accomplish what you need?From https://github.com/angular/material2/blob/master/src/lib/autocomplete/autocomplete-trigger.ts#L160
jefersonestevo commentedon Mar 17, 2017
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.
<md-autocomplete (onSelected)="myCallbackFunction($event)" .....willshowell commentedon Mar 17, 2017
You can also wire up a listener to
md-optionif you'd like. See #3576.Note: the api for
md-optionchanges as of #2722 to support multi select (in case you're using the latest builds)jefersonestevo commentedon Mar 17, 2017
Great! I can use that for now. Thanks @willshowell
jefersonestevo commentedon Mar 29, 2017
@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
wulfsberg commentedon Apr 18, 2017
Just came across this randomly, and wanted to mentioned that the official styleguide discourages the "on-" prefix for output events.
https://angular.io/docs/ts/latest/guide/style-guide.html#!#05-16
feat(autocomplete): emit event when an option is selected
liri2006 commentedon Jul 2, 2017
+1
feat(autocomplete): emit event when an option is selected
feat(autocomplete): emit event when an option is selected
feat(autocomplete): emit event when an option is selected (#4187)
angular-automatic-lock-bot commentedon Sep 6, 2019
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.