Thursday, 1 December 2022

mutli select drop down angular

<mat-form-field>

<mat-select placeholder="Documents to Export:" [formControl]="documents" multiple>

<mat-option *ngFor="let doc of documentList" [value]="doc.value" (onSelectionChange)="onSelect($event)">{{doc.value}}</mat-option>

<div style="margin: 10px; float: right;">

      <button [disabled]="document" mat-raised-button color="primary">Export Images</button>

    </div>

    </mat-select>

  </mat-form-field>

documents = new FormControl();
  selectedDocsany = [];

TS:

 onSelect(event) {

    if (event.isUserInput) {

      if (event.source.selected) {

        this.selectedDocs.push(event.source.value);

      } else {

        this.selectedDocs = this.selectedDocs.filter(d => d !== event.source.value)

      }

    }

    console.log(this.selectedDocs);

  }



No comments:

Post a Comment

7 Common mistakes in Dot Net — You can avoid

  There are many common mistakes made during .NET (ASP.NET, .NET Core) development, which affect performance, security, and code… Code Crack...