If all of the main code structure/configuration answers above don't solve your issue, here's one more thing to check: make sure that you haven't in some way invalidated your <input>
tag.
For instance, I received the same mat-form-field must contain a MatFormFieldControl
error message after accidentally putting a required
attribute after a self-closing slash /
, which effectively invalidated my <input/>
. In other words, I did this (see the end of the input tag attributes):
wrong:
<input matInput type="text" name="linkUrl" [formControl]="listingForm.controls['linkUrl']" /required>
right:
<input matInput type="text" name="linkUrl" [formControl]="listingForm.controls['linkUrl']" required/>
If you make that mistake or something else to invalidate your <input>
, then you could get the mat-form-field must contain a MatFormFieldControl
error. Anyway, this is just one more thing to look for as you're debugging.