mat-form-field must contain a MatFormFieldControl and already imported

Actually the error doesn’t mean a module import problem, but that you’re using the mat-form-field without a valid control.

The problem is here :

<mat-form-field>
    <mat-checkbox formControlName="active">Active</mat-checkbox>
</mat-form-field>

MatChebox isn’t intended to be contained in a mat-form-field but yeah its name is not very clear … Keep just in mind that mat-form-field is the component that handles underline + hint + floating label + errors, etc …

The list of supported child component is : input / textarea / select / chip-list (see https://material.angular.io/components/form-field/overview)

Leave a Comment