Value must be an array in multiple-selection mode in angular material mat-select

Discussão em 'Angular' iniciado por user824624, Dezembro 17, 2024.

  1. user824624

    user824624 Guest

    I am using angular material mat-select component.

    <mat-table [dataSource]="dataSource" class="mat-elevation-z8" matSort >

    <ng-container matColumnDef="sensitive">
    <mat-header-cell class="table-header header-p" *matHeaderCellDef> <b>sensitive</b> </mat-header-cell>
    <mat-cell class="table-content context-position " *matCellDef="let element" >
    <mat-select placeholder="sensitive" multiple [(ngModel)]="element.sensitive" >
    <mat-option *ngFor="let type of sensitiveList" [value]="type">{{type}}</mat-option>
    </mat-select>
    </mat-cell>
    </ng-container>

    <mat-header-row class="table-header-row" *matHeaderRowDef="displayedColumns"></mat-header-row>
    <mat-row [ngClass]="((i%2) == 1) ? 'table-content-row-single' : 'table-content-row-double'" *matRowDef="let row; columns: displayedColumns;"></mat-row>
    </mat-table>


    typescript sensitiveList : string[] = [ 'none', 'sensitive']; for(var i=0;i
    why running the code gives me an error

    Value must be an array in multiple-selection mode

    Continue reading...

Compartilhe esta Página