Error: mat-form-field must contain a MatFormFieldControl
See original GitHub issueDescribe the bug Receive the error when ng-select is wrapped inside a mat-form-field element
To Reproduce Steps to reproduce the behavior:
- Create a Reactive Form
- Wrap ng-select component inside mat-form-field element
- Check console to see error
Expected behavior ng-select should not break
Code
<mat-grid-tile [colspan]=1 [rowspan]=1>
<mat-form-field>
<ng-select matInput placeholder="Select country" #countrySelect [items]="country$" [selectOnTab]="true"
bindValue="id" labelForId="name" [formControl]="countryFormControl">
</ng-select>
</mat-form-field>
</mat-grid-tile>
Additional context The problem seems to be ng-select not having an matInput directive which is shared across mat-form-field chlidren.
Have added the Material Modules: Form, Input, Select https://github.com/angular/material2/issues/7898
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (1 by maintainers)
Top 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 >Error: mat-form-field must contain a MatFormFieldControl ...
Bug, feature request, or proposal: When doing a karma/jasmine test I get an error on the tag. This in combination with a.
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 >mat-form-field must contain a MatFormFieldControl - Edureka
I am getting this error: "mat-form-field must contain a MatFormFieldControl" in the console. How can I fix this?
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Dsupreme @kelvinlouis @davdinesh I have made a Material form field wrapper of
ng-select
(demo), it’s a component of Material extended library. Material Extensions: https://github.com/ng-matero/extensions@kelvinlouis I have created a directive to support the MatFormFieldControl. SCSS file needs a little more polishing but it works as expected. https://gist.github.com/jean-merelis/44a3ed842c24e99d38cd2f1e9249c473#file-ng-select-directive-ts