feat(forms): add hasError and getError to AbstractControlDirective (#11985)
Allows cleaner expressions in template-driven forms. Before: <label>Username</label><input name="username" ngModel required #username="ngModel"> <div *ngIf="username.dirty && username.control.hasError('required')">Username is required</div> After: <label>Username</label><input name="username" ngModel required #username="ngModel"> <div *ngIf="username.dirty && username.hasError('required')">Username is required</div> Fixes #7255
This commit is contained in:

committed by
Alex Rickabaugh

parent
24facdea2d
commit
592f40aa9c
2
tools/public_api_guard/forms/index.d.ts
vendored
2
tools/public_api_guard/forms/index.d.ts
vendored
@ -84,6 +84,8 @@ export declare abstract class AbstractControlDirective {
|
||||
valid: boolean;
|
||||
value: any;
|
||||
valueChanges: Observable<any>;
|
||||
getError(errorCode: string, path?: string[]): any;
|
||||
hasError(errorCode: string, path?: string[]): boolean;
|
||||
reset(value?: any): void;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user