Matthew Dewell
Matthew Dewell

Reputation: 573

Set option selection on mat-select to return placeholder after selection

I have the following Angular 6 code:

https://stackblitz.com/edit/angular-pl9wkw

I'm tryin g to make the select dropdown reset to the place holder once a selection has been made. I am using these two lines to try and reference the process:

@ViewChild('selectDropdown') selectDropdown: MatSelect;

and

this.selectDropdown.AppComponent.reset();

Alas, it does not work to set the dropdown back to the placeholder. I know that it can be set back to the placeholder, because I have the blank <mat-option></mat-option> selectable, and once you do select it, it sets it back to the placeholder.

Any thoughts ... anyone.

Upvotes: 3

Views: 5749

Answers (2)

ResolveError
ResolveError

Reputation: 155

In your Onchange make following change

this.selectDropdown.value.reset();

Upvotes: 0

Marshal
Marshal

Reputation: 11101

In your onChange method make the following change.

this.selectDropdown.value = [];
  // this.selectDropdown.AppComponent.reset();

Upvotes: 3

Related Questions