mardi 12 janvier 2021

Bind data to checkbox in angular material table using formcontrol. Data is available as list of true,false values

HTML

<ng-container matColumnDef="view">
    <mat-header-cell *matHeaderCellDef mat-sort-header>View</mat-header-cell>
       <mat-cell *matCellDef="let element; let i=index"> 
          <mat-checkbox formControlName="view" (change)=updateCheckedList(element)>
         </mat-checkbox>
       </mat-cell>
</ng-container>  ```

**TS**

view = [true,false,false,true]

createRoleForm(): FormGroup
  {
      return this._formBuilder.group({
          id              : [this.role.id],
          name            : [this.role.name],
         // view : 

      });
  }

I need to check the check boxes which are in the material table(view column) according to values of view list.




Aucun commentaire:

Enregistrer un commentaire