Skip to content

Autocomplete optionSelections to return one observable rather than an array #3205

Closed

Description

@christikaes

Bug, feature request, or proposal:

It would be easier to consume optionSelections if it returned a single observable that streamed which option was selected rather than an array, or alternatively emitted a change event like mdSelect.

The modification would be to this function:
https://github.com/angular/material2/blob/master/src/lib/autocomplete/autocomplete-trigger.ts#L163

What is the expected behavior?

The user should be able to call

trigger.optionSelections.subscribe(optionSelected => {
    // do stuff with the selected option
})

or alternatively listen to a change event

What is the current behavior?

Currently, to listen to what option changed, I have to subscribe to each one of the observes in optionSelections[]

Is there anything else we should know?

You guys are awesome :D I love angular2 material!!
🎆 Wooo autocomplete 🎆

Activity

  1. crisbeto commented on Feb 20, 2017

    @crisbeto
    Member

    FWIW, you can still do Observable.merge(...trigger.optionSelections) to subscribe to all of them at once.

  2. added a commit that references this issue on Feb 20, 2017
    ebcc2cf
  3. added
    feature
    P5
    on Feb 21, 2017
  4. sumpton commented on Feb 21, 2017

    @sumpton

    Material2 is great. Thank you.

    Is there an example of how to use MdAutocompleteTrigger and optionSelections?

  5. crisbeto commented on Feb 21, 2017

    @crisbeto
    Member

    @sumpton you can query for it with @ViewChild(mdAutocompleteTrigger) which then gives you access to the option selections. We should probably do a separate change event at some point.

  6. added a commit that references this issue on Feb 21, 2017
    e3b2486
  7. added a commit that references this issue on Apr 16, 2017
    ac476e4
  8. 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.

  9. 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

    P5feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions