I've created an editable using Angular Material, when a row is in an editable state each cell will show an input field depending on what data type is being displayed, e.g. if the cell is a string it will have an input field of type 'text'.
<mat-form-field>
<mat-label> {{column}} </mat-label>
<input type="text" matInput [(ngModel)]="element[column]"/>
</mat-form-field>
This works fine when using either text or number but I want to have a boolean checkbox as well, but when I try to use mat-checkbox
instead of input I get an error 'mat-form-field must contain a MatFormFieldControl.'. Even though I'm using ngModel
the same as I am with text and numbers.
<div *ngIf="column === 'checkType'>
<mat-checkbox [(ngModel)]="element[column]"></mat-checkbox>
</div>
Any help would be greatly appreciated.