'mat-radio-button' throwing no value accessor for form control
See original GitHub issueI just tried to bind formcontrolName
with mat-radio-button
HTML
<div [formGroup]="sampleFormGroup">
<mat-radio-group class="radio-btn-wrapper">
<mat-radio-button id="sample" (click)="valuechange('sampleVal')" name="sample" value="sampleVal" [checked]="sampleVal" formControlName="sampleType"></mat-radio-button>
</mat-radio-group>
</div>
TypeScript
sampleType = new FormControl('', []);
ngOnInit() {
this.sampleFormGroup = new FormGroup({
sampleType: this.sampleType
})
}
but I’m getting console error as
No value accessor for form control with name: 'sample'
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
<mat-radio-button> : No value accessor - Stack Overflow
Try to set formControlName="SearchType" on <mat-radio-group> and not on <mat-radio-button> .
Read more >Material radio-button, getting "ERROR Error: No value ... - Reddit
I am trying to use material radio buttons in a reactive form but get the error message ERROR Error: No value accessor for...
Read more >[Solved] ERROR Error: No value accessor for form control with ...
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:....
Read more >Angular 7 - No Value Accessor For Form Control With Name
I fixed this error by adding the namefieldName ngDefaultControl attributes to the element that carries the [ngModel] attribute. I had the same problem....
Read more >No value accessor for form control with name: ''-angular.js
You can't apply a formControlName directive to an strong tag. It must be applied on a form field tag ( select , input...
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
Try to set
formControlName="sampleType"
on<mat-radio-group>
and not on<mat-radio-button>
. It should works.@josephperrott I would like this ticket reopened as with the example code taken from the material site a spec fails with the same error:
Taken from this link: https://material.angular.io/components/radio/examples
You have to stop using the ngModel way of doing things to get this to work and that doesn’t seem right to me.
The error again is: Error: No value accessor for form control with unspecified name attribute
Either the documentation isn’t quite right or mat-radio-group should support the ngModel. I can create a new ticket if needed.