/
githubmirror
/
angular
Обзор
Документация
Войти
/
githubmirror
/
angular
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/forms/src/directives/template_driven_errors.ts
78 строк
2 KB
Joey Perrott
refactor: update license text to point to angular.dev (#57901)
24 сен 2024, 16:33
24 сен 2024, 16:33
9dbe6fc
Код
Авторство
О чём код?
/** * @license * Copyright Google LLC 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.dev/license */ import {ɵRuntimeError as RuntimeError} from '@angular/core'; import {RuntimeErrorCode} from '../errors'; import { formControlNameExample, formGroupNameExample, ngModelGroupExample, ngModelWithFormGroupExample, } from './error_examples'; export function modelParentException(): Error { return new RuntimeError( RuntimeErrorCode.NGMODEL_IN_FORM_GROUP, ` ngModel cannot be used to register form controls with a parent formGroup directive. Try using formGroup's partner directive "formControlName" instead. Example: ${formControlNameExample} Or, if you'd like to avoid registering this form control, indicate that it's standalone in ngModelOptions: Example: ${ngModelWithFormGroupExample}`, ); } export function formGroupNameException(): Error { return new RuntimeError( RuntimeErrorCode.NGMODEL_IN_FORM_GROUP_NAME, ` ngModel cannot be used to register form controls with a parent formGroupName or formArrayName directive. Option 1: Use formControlName instead of ngModel (reactive strategy): ${formGroupNameExample} Option 2: Update ngModel's parent be ngModelGroup (template-driven strategy): ${ngModelGroupExample}`, ); } export function missingNameException(): Error { return new RuntimeError( RuntimeErrorCode.NGMODEL_WITHOUT_NAME, `If ngModel is used within a form tag, either the name attribute must be set or the form control must be defined as 'standalone' in ngModelOptions. Example 1: <input [(ngModel)]="person.firstName" name="first"> Example 2: <input [(ngModel)]="person.firstName" [ngModelOptions]="{standalone: true}">`, ); } export function modelGroupParentException(): Error { return new RuntimeError( RuntimeErrorCode.NGMODELGROUP_IN_FORM_GROUP, ` ngModelGroup cannot be used with a parent formGroup directive. Option 1: Use formGroupName instead of ngModelGroup (reactive strategy): ${formGroupNameExample} Option 2: Use a regular form tag instead of the formGroup directive (template-driven strategy): ${ngModelGroupExample}`, ); }