import { ControlValueAccessor } from '@angular/forms' ; export class NgModelBase implements ControlValueAccessor { public onTouchedCallback : ( ) => { } ; public onChangeCallback : ( _ : any ) => { } ; public _innerValue : any ; set value ( v ) { if ( v !== this . _innerValue ) { this . _innerValue = v ; this . onChangeCallback ( v ) ; } } get value ( ) : any { return this . _innerValue ; } writeValue ( v ) { if ( v !== this . _innerValue ) { this . _innerValue = v ; } } registerOnChange ( fn ) { this . onChangeCallback = fn ; } registerOnTouched ( fn ) { this . onTouchedCallback = fn ; } }