My parent component uses a FormGroup and I expect the child components to report value changes to its parent. I try to solve this by using NG_VALUE_ACCESSOR in the child component to allow it to behave as a form field. As I've understood it one should use the 4 following functions
writeValue(value) {
this.value = value;
}
registerOnChange(fn: any) {
this.onChange = fn;
}
registerOnTouched(fn: any) {
this.onTouch = fn;
}
setDisabledState?(isDisabled: boolean): void {
this.isDisabled = isDisabled;
}
in order to behave as a form field. This is my current non-working solution:
https://stackblitz.com/edit/angular-ivy-tpneik?file=src%2Fapp%2Fapp.component.ts
The current error says:
Error: No value accessor for form control with path: 'ok -> isChecked'
The goal is to have a child component (and possible more) that can report its valuechanges correctly to the parent form in the parent component. How can I approach this problem?