refactor: move angular source to /packages rather than modules/@angular
This commit is contained in:
64
packages/forms/src/directives/error_examples.ts
Normal file
64
packages/forms/src/directives/error_examples.ts
Normal file
@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
|
||||
export const FormErrorExamples = {
|
||||
formControlName: `
|
||||
<div [formGroup]="myGroup">
|
||||
<input formControlName="firstName">
|
||||
</div>
|
||||
|
||||
In your class:
|
||||
|
||||
this.myGroup = new FormGroup({
|
||||
firstName: new FormControl()
|
||||
});`,
|
||||
|
||||
formGroupName: `
|
||||
<div [formGroup]="myGroup">
|
||||
<div formGroupName="person">
|
||||
<input formControlName="firstName">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
In your class:
|
||||
|
||||
this.myGroup = new FormGroup({
|
||||
person: new FormGroup({ firstName: new FormControl() })
|
||||
});`,
|
||||
|
||||
formArrayName: `
|
||||
<div [formGroup]="myGroup">
|
||||
<div formArrayName="cities">
|
||||
<div *ngFor="let city of cityArray.controls; let i=index">
|
||||
<input [formControlName]="i">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
In your class:
|
||||
|
||||
this.cityArray = new FormArray([new FormControl('SF')]);
|
||||
this.myGroup = new FormGroup({
|
||||
cities: this.cityArray
|
||||
});`,
|
||||
|
||||
ngModelGroup: `
|
||||
<form>
|
||||
<div ngModelGroup="person">
|
||||
<input [(ngModel)]="person.name" name="firstName">
|
||||
</div>
|
||||
</form>`,
|
||||
|
||||
ngModelWithFormGroup: `
|
||||
<div [formGroup]="myGroup">
|
||||
<input formControlName="firstName">
|
||||
<input [(ngModel)]="showMoreControls" [ngModelOptions]="{standalone: true}">
|
||||
</div>
|
||||
`
|
||||
};
|
||||
|
Reference in New Issue
Block a user