/** * @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 {BaseException} from '@angular/core'; import {FormErrorExamples as Examples} from './error_examples'; export class ReactiveErrors { static controlParentException(): void { throw new BaseException( `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 BaseException( `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 BaseException(`formGroup expects a FormGroup instance. Please pass one in. Example: ${Examples.formControlName}`); } static groupParentException(): void { throw new BaseException( `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 BaseException( `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) }); `); } }