No value accessor for from control
See original GitHub issueBug, feature request, or proposal:
Bug
What is the expected behavior?
There should be an value accessor.
What is the current behavior?
main.987e5bf….bundle.js:17 EXCEPTION: No value accessor for form control with name: 'username'
What are the steps to reproduce?
This bug occurs only if you run ng build --prod
.
Use angular-cli@webpack to create a new project.
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ReactiveFormsModule } from '@angular/forms';
import { MdCardModule } from '@angular2-material/card/card';
import { MdInputModule } from '@angular2-material/input/input';
import { MdButtonModule } from '@angular2-material/button/button';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
CommonModule,
ReactiveFormsModule,
MdCardModule,
MdInputModule,
MdButtonModule,
],
providers: [],
entryComponents: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule {
}
<form [formGroup]="form">
<md-card>
<md-card-title>{{title}}</md-card-title>
<md-card-content>
<md-input placeholder="Username" formControlName="username"></md-input>
<md-input placeholder="Password" formControlName="password"></md-input>
</md-card-content>
<md-card-actions align="end">
<button md-button color="primary" type="submit">LOGIN</button>
</md-card-actions>
</md-card>
</form>
What is the use-case or motivation for changing an existing behavior?
Build an Angular2 app with prod flag.
Which versions of Angular, Material, OS, browsers are affected?
Angular@RC.5, Angular-CLI@webpack.2, Material@alpha.7-2, OSX 10.11.5
Is there anything else we should know?
As mentioned above, this only happens with the prod flag
Issue Analytics
- State:
- Created 7 years ago
- Comments:17 (2 by maintainers)
Top Results From Across the Web
No value accessor for form control [duplicate] - Stack Overflow
Show activity on this post. the formControlName is not located on the value accessor element. or you're not importing the module for that...
Read more >Improve error message "No value accessor for form control ...
When you get the error No value accessor for form control with unspecified name attribute , there are generally two things that possibly...
Read more >Creating a custom form control in Angular - Orjan De Smet
If you'd just use these directives, you'd get the error “No value accessor for form control with name: <the name of your control>”....
Read more >No Value Accessor Error in Angular Tests - Damir's Corner
Error: No value accessor for form control with unspecified name attribute. The call stack wasn't helpful at all. It included only Angular ...
Read more >NG01203: You must register an `NgValueAccessor` with a ...
If you defined a custom form control, did you remember to provide a value accessor? · Did you put ngModel on an element...
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
With
material 2.0.0-beta.3
we now have to import every modules one by one and I forgotMdSelectModule
which gave me this error. (might help someone)I’m also getting this error using ngModel on an input that is not even inside of a form.
Getting the error
No value accessor for form control with unspecified name
within browser_adapter.js.I have FormsModule and I just tested with ReactiveFormsModule as well after reading this thread. Still getting the same error.
EDIT: I replaced md-input with a regular input tag and the page works as expected, this is defintely an issue with angular/material2.
These work fine: