Let's say I am creating a custom checkbox component, that has a checkbox inside of it. I just want to use the component, just so I can style it on certain conditions. As far as I know, I need to implement ControlValueAccessor interface to be able to use my component as a form component. Is there a way to provide the element inside as the ControlValueAccessor, rather than writing the whole boilerplate.
Something like this,
@Component({
selector: 'app-custom-checkbox',
templateUrl: './custom-checkbox.component.html',
styleUrls: ['./custom-checkbox.component.scss'],
providers: [{
provide: NG_VALUE_ACCESSOR,
useExisting: "" // Use the checkbox in the template
}]
})
export class CustomCheckboxComponent {}