Cannot create a custom MatFormFieldControl that implement ControlValueAccessor
See original GitHub issueBug, feature request, or proposal:
Bug/Feature Request
What is the expected behavior?
The guide “Creating a custom form field control” should give an example with a custom MatFormFieldControl that implement ControlValueAccessor.
What is the current behavior?
The guide advise us to use:
constructor(..., @Optional() @Self() public ngControl: NgControl) { ... }
But it leads to a cyclic dependancy error:
ERROR Error: Uncaught (in promise): Error: Template parse errors:
Cannot instantiate cyclic dependency! NgControl
What are the steps to reproduce?
Here is a StackBlitz
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
@angular/material: 2.0.0-beta.12 @angular/core: 4.4.4 @angular/cli: 1.4.4 typescript: 2.4.2 Windows 10 64bit Chrome/Firefox/Edge
Is there anything else we should know?
I do not think so.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:10
- Comments:23 (2 by maintainers)
Top Results From Across the Web
MatFormFieldControl that implements ControlValueAccessor ...
I'm trying to create custom form control by implementing MatFormFieldControl, ControlValueAccessor and Validator interfaces.
Read more >Cannot create a custom MatFormFieldControl that implement ...
What is the expected behavior? The guide "Creating a custom form field control" should give an example with a custom MatFormFieldControl that implement...
Read more >Creating a custom form field control | Angular Material
The first step is to provide our new component as an implementation of the MatFormFieldControl interface that the <mat-form-field> knows how to work...
Read more >Creating a custom form field control compatible with Reactive ...
]export class FormRichEditorComponent implements OnInit, ControlValueAccessor, MatFormFieldControl<any>) {... This sets up our component so it ...
Read more >Angular Custom Form Controls - Complete Guide
Introduction to the ControlValueAccessor interface; Implementing the ... In order to know how to build a custom form control, ...
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
Please provide a tutorial of a MatFormFieldControl that implements ControlValueAccessor…
@ADegele Yes ! I struggled a lot with it !
Here is what I have done: