menu
menuAPI
Abstract class for top-level form directives (FormArrayDirective, FormGroupDirective) who bind an
existing Form to a DOM element.
abstract class AbstractFormDirective extends ControlContainer implements Form ,OnChanges ,OnDestroy { constructor(validators: (ValidatorFn | Validator)[], asyncValidators: (AsyncValidatorFn | AsyncValidator)[], callSetDisabledState?: SetDisabledStateOption | undefined): AbstractFormDirective; readonly submitted: boolean; directives: FormControlName[]; abstract form: AbstractControl<any, any, any>; abstract ngSubmit: EventEmitter<any>; protected onChanges(changes: { [propName: string]: SimpleChange<any>; }): void; protected onDestroy(): void; readonly formDirective: Form; abstract readonly control: AbstractControl<any, any, any>; readonly path: string[]; addControl(dir: FormControlName): FormControl<any>; getControl(dir: FormControlName): FormControl<any>; removeControl(dir: FormControlName): void; addFormGroup(dir: FormGroupName): void; removeFormGroup(dir: FormGroupName): void; getFormGroup(dir: FormGroupName): FormGroup<any>; getFormArray(dir: FormArrayName): FormArray<any>; addFormArray(dir: FormArrayName): void; removeFormArray(dir: FormArrayName): void; updateModel(dir: FormControlName, value: any): void; onReset(): void; resetForm(value?: any, options?: { onlySelf?: boolean | undefined; emitEvent?: boolean | undefined; }): void; onSubmit($event: Event): boolean; override name: string | number | null; override readonly value: any; override readonly valid: boolean | null; override readonly invalid: boolean | null; override readonly pending: boolean | null; override readonly disabled: boolean | null; override readonly enabled: boolean | null; override readonly errors: ValidationErrors | null; override readonly pristine: boolean | null; override readonly dirty: boolean | null; override readonly touched: boolean | null; override readonly status: string | null; override readonly untouched: boolean | null; override readonly statusChanges: any; override readonly valueChanges: any; override readonly validator: ValidatorFn | null; override readonly asyncValidator: AsyncValidatorFn | null; override reset(value?: any): void; override hasError(errorCode: string, path?: string | (string | number)[] | undefined): boolean; override getError(errorCode: string, path?: string | (string | number)[] | undefined): any;}
booleanReports whether the form submission has been triggered.
FormControlName[]Tracks the list of added FormControlName instances
AbstractControl<any, any, any>Tracks the form bound to this directive.
EventEmitter<any>Emits an event when the form submission has been triggered.
void{ [propName: string]: SimpleChange<any>; }voidvoidvoidvoid{ [propName: string]: SimpleChange<any>; }voidvoidvoidFormReturns this directive's instance.
AbstractControl<any, any, any>Returns the Form bound to this directive.
string[]Returns an array representing the path to this group. Because this directive always lives at the top level of a form, it always an empty array.
FormControl<any>Retrieves the FormControl instance from the provided FormControlName directive
FormControl<any>voidRemoves the FormControlName instance from the internal list of directives
voidvoidPerforms the necessary cleanup when a FormGroupName directive instance is removed from the
view.
voidFormGroup<any>Retrieves the FormGroup for a provided FormGroupName directive instance
FormGroup<any>FormArray<any>Retrieves the FormArray for a provided FormArrayName directive instance.
FormArray<any>voidPerforms the necessary cleanup when a FormArrayName directive instance is removed from the
view.
voidvoidSets the new value for the provided FormControlName directive.
anyThe new value for the directive's control.
voidvoidMethod called when the "reset" event is triggered on the form.
voidvoidResets the form to an initial value and resets its submitted status.
anyThe new value for the form.
{ onlySelf?: boolean | undefined; emitEvent?: boolean | undefined; }voidbooleanMethod called with the "submit" event is triggered on the form.
Triggers the ngSubmit emitter to emit the "submit" event as its payload.
EventThe "submit" event object
booleanstring | number | nullThe name for the control
anyReports the value of the control if it is present, otherwise null.
boolean | nullReports whether the control is valid. A control is considered valid if no validation errors exist with the current value. If the control is not present, null is returned.
boolean | nullReports whether the control is invalid, meaning that an error exists in the input value. If the control is not present, null is returned.
boolean | nullReports whether a control is pending, meaning that async validation is occurring and errors are not yet available for the input value. If the control is not present, null is returned.
boolean | nullReports whether the control is disabled, meaning that the control is disabled in the UI and is exempt from validation checks and excluded from aggregate values of ancestor controls. If the control is not present, null is returned.
boolean | nullReports whether the control is enabled, meaning that the control is included in ancestor calculations of validity or value. If the control is not present, null is returned.
ValidationErrors | nullReports the control's validation errors. If the control is not present, null is returned.
boolean | nullReports whether the control is pristine, meaning that the user has not yet changed the value in the UI. If the control is not present, null is returned.
boolean | nullReports whether the control is dirty, meaning that the user has changed the value in the UI. If the control is not present, null is returned.
boolean | nullReports whether the control is touched, meaning that the user has triggered
a blur event on it. If the control is not present, null is returned.
string | nullReports the validation status of the control. Possible values include: 'VALID', 'INVALID', 'DISABLED', and 'PENDING'. If the control is not present, null is returned.
boolean | nullReports whether the control is untouched, meaning that the user has not yet triggered
a blur event on it. If the control is not present, null is returned.
anyReturns a multicasting observable that emits a validation status whenever it is calculated for the control. If the control is not present, null is returned.
anyReturns a multicasting observable of value changes for the control that emits every time the value of the control changes in the UI or programmatically. If the control is not present, null is returned.
ValidatorFn | nullSynchronous validator function composed of all the synchronous validators registered with this directive.
AsyncValidatorFn | nullAsynchronous validator function composed of all the asynchronous validators registered with this directive.
voidResets the control with the provided value if the control is present.
anyvoidbooleanReports whether the control with the given path has the error specified.
stringThe code of the error to check
string | (string | number)[] | undefinedA list of control names that designates how to move from the current control to the control that should be queried for errors.
booleanwhether the given error is present in the control at the given path.
If the control is not present, false is returned.
For example, for the following FormGroup:
form = new FormGroup({
address: new FormGroup({ street: new FormControl() })
});
The path to the 'street' control from the root form would be 'address' -> 'street'.
It can be provided to this method in one of two formats:
['address', 'street']'address.street'If no path is given, this method checks for the error on the current control.
anyReports error data for the control with the given path.
stringThe code of the error to check
string | (string | number)[] | undefinedA list of control names that designates how to move from the current control to the control that should be queried for errors.
anyerror data for that particular error. If the control or error is not present, null is returned.
For example, for the following FormGroup:
form = new FormGroup({
address: new FormGroup({ street: new FormControl() })
});
The path to the 'street' control from the root form would be 'address' -> 'street'.
It can be provided to this method in one of two formats:
['address', 'street']'address.street'