Richard Medeiros
Richard Medeiros

Reputation: 978

How to use the mdAutocomplete openPanel method

I'm trying to create a button that both clears an mdAutocomplete control and opens the panel.

Something like this:

clearValue() {
  this.stateCtrl.setValue("");
  this.trigger.openPanel();
}

here is a plunk for the full code: https://plnkr.co/edit/KC8f1bHaDpWXEkLxzLta?p=preview

If I put a break point in the clearValue function and call this.trigger.openPanel() in the console the panel opens, but when I just let the code run the panel never opens.

Upvotes: 1

Views: 308

Answers (1)

yurzui
yurzui

Reputation: 214235

The easist way to solve your problem is to prevent propagation to handler that closes popup:

(click)="clearValue(); $event.stopPropagation()"

Forked Plunker

Upvotes: 2

Related Questions