Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67411

I am getting this 'Error: mat-form-field must contain a matformfieldcontrol' while using mat native select

$
0
0

I am using angular material native select and getting 'error: mat-form-field must contain a matformfieldcontrol'

HTML :

<mat-form-field>
     <select matNativeControl formControlName="xyz" required>
             <option [value]="a">A</option>
             <option [value]="a">B</option>
             <option [value]="a">C</option>
     </select>
</mat-form-field>

I have imported MatFormFieldModule, MatInputModule, MatSelectModule, MatOptionModule, modules in my app.module.ts

app.module.ts :

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ReactiveFormsModule, FormsModule } from '@angular/forms';
import { MatFormFieldModule, MatInputModule, MatSelectModule, MatOptionModule } from '@angular/material';

@NgModule({
imports: [
    CommonModule,
    ReactiveFormsModule,
    FormsModule,
    MatFormFieldModule,
    MatInputModule,
    MatSelectModule,
    MatOptionModule
  ],
})

I have used <input> as well in the same form and that is working fine. But getting this particular error only in <select> . 

Could not find any solution for it.


Viewing all articles
Browse latest Browse all 67411

Trending Articles