Skip to content

md-autocomplete optionsSelection #3280

Closed

Description

@ambarkiy

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?

Activity

  1. kara commented on Feb 24, 2017

    @kara
    Contributor

    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

  2. ambarkiy commented on Feb 24, 2017

    @ambarkiy
    Author

    Thank you sorry

  3. ktersius commented on Mar 29, 2017

    @ktersius

    @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

  4. ambarkiy commented on Mar 29, 2017

    @ambarkiy
    Author

    thank you 're write

  5. angular-automatic-lock-bot commented on Sep 5, 2019

    @angular-automatic-lock-bot

    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.

  6. locked and limited conversation to collaborators on Sep 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions