For custom form components, is it possible to use DefaultValueAccessor instead of ControlValueAccessor?
One possible solution could be using ngDefaultControl
attribute on your custom component:
<div [formGroup]="form">
<jg-search formControlName="x" ngDefaultControl></jg-search>
^^^^^^^^^^^^^^^^
</div>
now all you need to do is to link your input
element with existing FormControl as follows:
@Component({
selector: 'jg-search',
template: `
<input [formControl]="ngControl.control">
`
})
export class MyInput {
constructor(public ngControl: NgControl) {}
}
For more detals see Ng-run Example