angular / angular/components

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

Aperta
#14,850 7 commenti 6 reazioni 0 assegnatari Vedi su GitHub
area: material/radio P3
Lingua principale
TypeScript
Stelle
25k
Fork
6.8k
Merge medio
1g 8h
PR unite (30g)
91

Descrizione

#### 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`)

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia eseguendo l’esempio StackBlitz che presenta l’errore in app/radio-overview-example.html e confrontalo con l’esempio native-radio in app/person-edit.component.ts. Riproduci l’errore segnalato per il FormArray dinamico e segui il percorso del controllo del modulo. Il lavoro è completato quando i controlli mat-radio-button sono associati correttamente nella tabella senza l’errore value-accessor.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
angular, typescript
Ambito
frontend
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.