refactor: move angular source to /packages rather than modules/@angular
This commit is contained in:
77
packages/forms/src/directives/reactive_errors.ts
Normal file
77
packages/forms/src/directives/reactive_errors.ts
Normal file
@ -0,0 +1,77 @@
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
|
||||
|
||||
import {FormErrorExamples as Examples} from './error_examples';
|
||||
|
||||
export class ReactiveErrors {
|
||||
static controlParentException(): void {
|
||||
throw new Error(
|
||||
`formControlName must be used with a parent formGroup directive. You'll want to add a formGroup
|
||||
directive and pass it an existing FormGroup instance (you can create one in your class).
|
||||
|
||||
Example:
|
||||
|
||||
${Examples.formControlName}`);
|
||||
}
|
||||
|
||||
static ngModelGroupException(): void {
|
||||
throw new Error(
|
||||
`formControlName cannot be used with an ngModelGroup parent. It is only compatible with parents
|
||||
that also have a "form" prefix: formGroupName, formArrayName, or formGroup.
|
||||
|
||||
Option 1: Update the parent to be formGroupName (reactive form strategy)
|
||||
|
||||
${Examples.formGroupName}
|
||||
|
||||
Option 2: Use ngModel instead of formControlName (template-driven strategy)
|
||||
|
||||
${Examples.ngModelGroup}`);
|
||||
}
|
||||
static missingFormException(): void {
|
||||
throw new Error(`formGroup expects a FormGroup instance. Please pass one in.
|
||||
|
||||
Example:
|
||||
|
||||
${Examples.formControlName}`);
|
||||
}
|
||||
|
||||
static groupParentException(): void {
|
||||
throw new Error(
|
||||
`formGroupName must be used with a parent formGroup directive. You'll want to add a formGroup
|
||||
directive and pass it an existing FormGroup instance (you can create one in your class).
|
||||
|
||||
Example:
|
||||
|
||||
${Examples.formGroupName}`);
|
||||
}
|
||||
|
||||
static arrayParentException(): void {
|
||||
throw new Error(
|
||||
`formArrayName must be used with a parent formGroup directive. You'll want to add a formGroup
|
||||
directive and pass it an existing FormGroup instance (you can create one in your class).
|
||||
|
||||
Example:
|
||||
|
||||
${Examples.formArrayName}`);
|
||||
}
|
||||
|
||||
static disabledAttrWarning(): void {
|
||||
console.warn(`
|
||||
It looks like you're using the disabled attribute with a reactive form directive. If you set disabled to true
|
||||
when you set up this control in your component class, the disabled attribute will actually be set in the DOM for
|
||||
you. We recommend using this approach to avoid 'changed after checked' errors.
|
||||
|
||||
Example:
|
||||
form = new FormGroup({
|
||||
first: new FormControl({value: 'Nancy', disabled: true}, Validators.required),
|
||||
last: new FormControl('Drew', Validators.required)
|
||||
});
|
||||
`);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user