[Solved] ERROR Error: No value accessor for form control with unspecified name attribute
[Solved] ERROR Error: No value accessor for form control with unspecified name attribute
This issue will occur due to lot of reasons, here I am writing my case to help someone,
Table of Contents
Issue:
This issue happened with angular 4 cli + angular material 2 for me.
I used mat-radio-button, mat-checkbox in my template page. But I missed to import the radio module and FormsModule in my app module.
Solutions:
Import all the respective modules in your module page [In this case MatCheckboxModule and MatRadioModule]. Ensure you have already imported FormsModule as well.
Issue code:
import { MatButtonModule, MatCheckboxModule, MatCardModule, MatInputModule } from ‘@angular/material’;
imports: [BrowserModule,BrowserAnimationsModule,MatButtonModule,MatCheckboxModule,FormsModule,HttpModule,MatCardModule,MatInputModule],
providers: [],
bootstrap: [AppComponent]
})
Resolved Code:
import { MatButtonModule, MatCheckboxModule, MatCardModule,MatInputModule, MatRadioModule } from ‘@angular/material’;
imports: [BrowserModule,BrowserAnimationsModule,MatButtonModule,MatCheckboxModule,FormsModule,HttpModule,MatCardModule,MatInputModule,MatRadioModule],
providers: [],
bootstrap: [AppComponent]
})
Hope it helps someone!