Czyszczenie mat-select w Angularze

0

Siema, macie jakieś pomysły jak wyczyścic wszystkie option w danym select?

<mat-select multiple formControlName="{{ items.name }}">
            <div class="filter-input-container">
              <app-filter-input></app-filter-input>
            </div>
            <div class="custom-panel">
              <mat-option
                *ngFor="let item of items.content"
                [value]=item
                >{{ item }}</mat-option
              >
            </div>
            <div class="panel-buttons">
              <button mat-button class="cancel" type="reset">Wyczyść</button>
              <button mat-button class="confirm" type="submit">
                Zatwierdź
              </button>
            </div>
          </mat-select>
0

this.items.content = []

Ale podejrzewam, że to podchwytliwe pytanie :>

1

Niejasno to napisałeś :P
Możesz wyczyścić formularz/kontrolkę, albo:

Dodasz do select template variable (#matSelect), podepniesz się w ts:

@ViewChild('matRef') matRef: MatSelect;

i w jakimś miejscu robisz deselect na wszystko:

this.matRef.options.forEach((data: MatOption) => data.deselect());

1 użytkowników online, w tym zalogowanych: 0, gości: 1