Should I use ControlValueAccessor If I want to create parent - child components with reactive forms transfering form data from child to parent form?

Viewed 15

I am a beginner in Angular.

I want to create a subcomponent with reactive form which transfer it's data to the parent component's reactive FormGroup.

I have a working demo: https://stackblitz.com/edit/angular-ivy-yxtxgr?file=src/app/app.component.ts

But I am not sure if this is the best way to do it.

I am particularly interested in this (https://angular.io/guide/built-in-directives#ngModel) :

"When you write an Angular component, you don't need a value accessor or NgModel if you name the value and event properties according to Angular's two-way binding syntax."

So, is my stackblitz "solution" with ControlValueAcessor the preferred way of doing this?

0 Answers
Related