angular / angular/components

MatRadioButton: Error: No value accessor for form control with path...

Offen
#14,850 7 Kommentare 6 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area: material/radio P3
Vorherrschende Sprache
TypeScript
Sterne
25k
Forks
6.8k
Ø Merge
1 T. 8 Std.
Gemergte PRs (30 T.)
91

Beschreibung

#### What is the expected behavior?

I'm trying to use the `mat-radio-button` inside an HTML table (agreed, the form is a bit stange). It's an array of data, for each row I need 2 radio buttons. I'm constructing the `FormArray` dynamically and then bind it into the HTML.

Note: Being in a table, where each of the grouped radio buttons is inside it's own ``, I cannot use `` but that shouldn't be an issue as I'm using the `name` attribute as you would with native controls.

#### What is the current behavior?

Right now the behavior is that I'm getting an error saying `No value accessor for form control with path: 'phoneNumbers -> 0 -> phone1'` etc...and hence the databinding doesn't work.

On the other side, if I change nothing else, but the `mat-radio-button` with native HTML radio buttons, everything works as expected (see repro stackblitz below).

#### What are the steps to reproduce?
Providing a StackBlitz reproduction is the *best* way to share your issue.

StackBlitz starter: https://goo.gl/wwnhMV

Example using HTML native radio buttons: https://stackblitz.com/edit/angular-reactiveforms-dynamic-formarray-binding?file=app/person-edit.component.ts

(Failing) example using `mat-radio-button`: https://stackblitz.com/edit/angular-4k8hf4-3egfsd?file=app%2Fradio-overview-example.html

#### Which versions of Angular, Material, OS, TypeScript, browsers are affected?

latest from the current docs (i.e. `v7.2`)

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne damit, das fehlschlagende StackBlitz-Beispiel in app/radio-overview-example.html auszuführen, und vergleiche es mit dem native-radio-Beispiel in app/person-edit.component.ts. Reproduziere den gemeldeten Fehler für das dynamische FormArray und verfolge den Pfad des Form-Control. Erledigt ist die Aufgabe, wenn die mat-radio-button-Controls in der Tabelle ohne den value-accessor-Fehler korrekt gebunden werden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, typescript
Bereich
frontend
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.