question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: mat-form-field must contain a MatFormFieldControl.

See original GitHub issue

Bug, feature request, or proposal:

When doing a karma/jasmine test I get an error on the <mat-form-field> tag. This in combination with a <mat-select>

<mat-form-field> <mat-select name="country" placeholder="Country" [(ngModel)]="address.countryName" class="input-full-width"> <mat-option *ngFor="let country of countries | orderBy: 'name'" [value]="country.name">{{ country.name }}</mat-option> </mat-select> </mat-form-field>

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Using angular 4.4.5 material 2.0.0-beta.12

Is there anything else we should know?

When running the project it’s working okay, but just the test gives an error and fails.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:10
  • Comments:39 (3 by maintainers)

github_iconTop GitHub Comments

935reactions
tomchovaneccommented, Oct 19, 2017

You have to add to app.module.ts:

import {MatInputModule} from '@angular/material';
@NgModule({
  imports: [
  ...
    MatInputModule
  ...
]


127reactions
Abdullah-FAlcommented, Oct 21, 2017

You have to add matInput to input

<div class="fields-container">
      <mat-form-field>
        <input matInput placeholder="Input">
      </mat-form-field>

    </div>
Read more comments on GitHub >

github_iconTop Results From Across the Web

mat-form-field must contain a MatFormFieldControl
Error: mat-form-field must contain a MatFormFieldControl. This error occurs when you have not added a form field control to your form field.
Read more >
mat-form-field must contain a MatFormFieldControl error fix in ...
This error occurs when you have missed to add a form field control to your form field. Table of Contents. what are form...
Read more >
mat-form-field must contain a MatFormFieldControl - Elite Corner
This error usually occurs in 4 scenarios when we missed to import module for specific component. Problem 1: MatInputModule or MatFormFieldModule ...
Read more >
mat-form-field must contain a MatFormFieldControl
mat -form-field must contain a MatFormFieldControl. I got an error while I was trying to add Angular material mat-form-field control. Here is how ......
Read more >
Form field
link Error: mat-form-field must contain a MatFormFieldControl ... This error occurs when you have not added a form field control to your form...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found