import { ValidationErrors } from '@angular/forms' ; import { ControlValueAccessor } from './control-value-accessor' ; import { AbstractControl } from './abstract-control' ; /**
 * A default ControlValueAccessor implementation
 */ export abstract class DefaultControlValueAccessor < T > implements ControlValueAccessor < T > { public abstract readonly control : AbstractControl < T | null > ; public writeValue ( value ) { this . control . setValue ( value , { emitEvent : false } ) ; } public registerOnChange ( onChange ) { this . control . valueChanges . subscribe ( onChange ) ; } public registerOnTouched ( ) { } public setDisabledState ( disabled ) { disabled ? this . control . disable ( { emitEvent : false } ) : this . control . enable ( { emitEvent : false } ) ; } public validate ( ) { return this . control . invalid ? { invalid : true } : null ; } }