42 lines
1.3 KiB
TypeScript
Raw Normal View History

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
2016-06-08 15:36:24 -07:00
import {AbstractControlDirective} from './abstract_control_directive';
import {ControlContainer} from './control_container';
import {ControlValueAccessor} from './control_value_accessor';
import {AsyncValidator, AsyncValidatorFn, Validator, ValidatorFn} from './validators';
2016-06-08 15:36:24 -07:00
function unimplemented(): any {
throw new Error('unimplemented');
}
2016-06-08 15:36:24 -07:00
/**
* A base class that all control directive extend.
* It binds a `FormControl` object to a DOM element.
2016-06-08 15:36:24 -07:00
*
* Used internally by Angular forms.
*
*
2016-06-08 15:36:24 -07:00
*/
export abstract class NgControl extends AbstractControlDirective {
/** @internal */
_parent: ControlContainer|null = null;
name: string|null = null;
valueAccessor: ControlValueAccessor|null = null;
/** @internal */
_rawValidators: Array<Validator|ValidatorFn> = [];
/** @internal */
_rawAsyncValidators: Array<AsyncValidator|AsyncValidatorFn> = [];
2016-06-08 15:36:24 -07:00
get validator(): ValidatorFn|null { return <ValidatorFn>unimplemented(); }
get asyncValidator(): AsyncValidatorFn|null { return <AsyncValidatorFn>unimplemented(); }
2016-06-08 15:36:24 -07:00
abstract viewToModelUpdate(newValue: any): void;
}