+
- }
- @if(actorForm.hasError('unambiguousRole') && (actorForm.touched || actorForm.dirty)) {
+ @if (actorForm.hasError('unambiguousRole') && (actorForm.touched || actorForm.dirty)) {
Name cannot match role.
@@ -79,15 +81,15 @@
name="skill"
required [(ngModel)]="actor.skill"
#skill="ngModel">
- @for(skill of skills; track $index) {
+ @for (skill of skills; track $index) {
}
- @if(skill.errors && skill.touched) {
+ @if (skill.errors && skill.touched) {
- @if(skill.errors['required']) {
- Power is required.
+ @if (skill.errors['required']) {
+
Skill is required.
}
}
@@ -95,12 +97,14 @@
Complete the form to enable the Submit button.
+ [disabled]="actorForm.invalid">Submit
+
+ (click)="actorForm.resetForm({})">Reset
+
You've submitted your actor, {{ actorForm.value.name }}!
diff --git a/adev/src/content/examples/form-validation/src/app/template/actor-form-template.component.ts b/adev/src/content/examples/form-validation/src/app/template/actor-form-template.component.ts
index 6171e67ee06..7738f3e6e0c 100644
--- a/adev/src/content/examples/form-validation/src/app/template/actor-form-template.component.ts
+++ b/adev/src/content/examples/form-validation/src/app/template/actor-form-template.component.ts
@@ -2,12 +2,18 @@ import {Component} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {UnambiguousRoleValidatorDirective} from '../shared/unambiguous-role.directive';
import {ForbiddenValidatorDirective} from '../shared/forbidden-name.directive';
+import {UniqueRoleValidatorDirective} from '../shared/role.directive';
@Component({
selector: 'app-actor-form-template',
templateUrl: './actor-form-template.component.html',
styleUrls: ['./actor-form-template.component.css'],
- imports: [UnambiguousRoleValidatorDirective, FormsModule, ForbiddenValidatorDirective],
+ imports: [
+ UnambiguousRoleValidatorDirective,
+ FormsModule,
+ ForbiddenValidatorDirective,
+ UniqueRoleValidatorDirective,
+ ],
})
export class ActorFormTemplateComponent {
skills = ['Method Acting', 'Singing', 'Dancing', 'Swordfighting'];
diff --git a/adev/src/content/examples/forms-overview/src/app/app.component.html b/adev/src/content/examples/forms-overview/src/app/app.component.html
index a274b28459c..ca482d3564e 100644
--- a/adev/src/content/examples/forms-overview/src/app/app.component.html
+++ b/adev/src/content/examples/forms-overview/src/app/app.component.html
@@ -3,8 +3,8 @@
Reactive
-
+
Template-Driven
-
\ No newline at end of file
+
diff --git a/adev/src/content/examples/forms/src/app/actor-form/actor-form.component.html b/adev/src/content/examples/forms/src/app/actor-form/actor-form.component.html
index c332caaa47a..6eea779b5a1 100644
--- a/adev/src/content/examples/forms/src/app/actor-form/actor-form.component.html
+++ b/adev/src/content/examples/forms/src/app/actor-form/actor-form.component.html
@@ -33,7 +33,9 @@
skill is required
@@ -132,7 +134,9 @@
@@ -168,7 +172,9 @@
diff --git a/adev/src/content/examples/forms/src/app/actor-form/actor-form.component.ts b/adev/src/content/examples/forms/src/app/actor-form/actor-form.component.ts
index 45fd88380f4..c66738819bc 100644
--- a/adev/src/content/examples/forms/src/app/actor-form/actor-form.component.ts
+++ b/adev/src/content/examples/forms/src/app/actor-form/actor-form.component.ts
@@ -4,12 +4,13 @@ import {Component} from '@angular/core';
import {Actor} from '../actor';
import {FormsModule} from '@angular/forms';
+import {JsonPipe} from '@angular/common';
// #docregion imports
@Component({
selector: 'app-actor-form',
templateUrl: './actor-form.component.html',
- imports: [FormsModule],
+ imports: [FormsModule, JsonPipe],
})
export class ActorFormComponent {
// #enddocregion imports
diff --git a/adev/src/content/examples/forms/src/app/app.component.html b/adev/src/content/examples/forms/src/app/app.component.html
index d51bf2f406e..2382d9e1f17 100644
--- a/adev/src/content/examples/forms/src/app/app.component.html
+++ b/adev/src/content/examples/forms/src/app/app.component.html
@@ -1 +1 @@
-
\ No newline at end of file
+
diff --git a/adev/src/content/examples/reactive-forms/src/app/app.component.1.html b/adev/src/content/examples/reactive-forms/src/app/app.component.1.html
index 57ca7e22fbe..4a4410085e1 100644
--- a/adev/src/content/examples/reactive-forms/src/app/app.component.1.html
+++ b/adev/src/content/examples/reactive-forms/src/app/app.component.1.html
@@ -2,9 +2,9 @@
Reactive Forms
-
+
-
-
\ No newline at end of file
+
+
diff --git a/adev/src/content/examples/reactive-forms/src/app/app.component.html b/adev/src/content/examples/reactive-forms/src/app/app.component.html
index 285c0c641d8..7aabd75adec 100644
--- a/adev/src/content/examples/reactive-forms/src/app/app.component.html
+++ b/adev/src/content/examples/reactive-forms/src/app/app.component.html
@@ -5,10 +5,10 @@
-@if (showNameEditor) {
-
+@if (showNameEditor()) {
+
}
-@if (showProfileEditor) {
-
+@if (showProfileEditor()) {
+
}
diff --git a/adev/src/content/examples/reactive-forms/src/app/app.component.ts b/adev/src/content/examples/reactive-forms/src/app/app.component.ts
index 64fd7d57f4d..1aee8ce5318 100644
--- a/adev/src/content/examples/reactive-forms/src/app/app.component.ts
+++ b/adev/src/content/examples/reactive-forms/src/app/app.component.ts
@@ -1,4 +1,6 @@
-import {Component} from '@angular/core';
+import {Component, computed, signal, WritableSignal} from '@angular/core';
+import {NameEditorComponent} from './name-editor/name-editor.component';
+import {ProfileEditorComponent} from './profile-editor/profile-editor.component';
export type EditorType = 'name' | 'profile';
@@ -6,19 +8,15 @@ export type EditorType = 'name' | 'profile';
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
+ imports: [NameEditorComponent, ProfileEditorComponent],
})
export class AppComponent {
- editor: EditorType = 'name';
+ editor: WritableSignal
= signal('name');
- get showNameEditor() {
- return this.editor === 'name';
- }
-
- get showProfileEditor() {
- return this.editor === 'profile';
- }
+ showNameEditor = computed(() => this.editor() === 'name');
+ showProfileEditor = computed(() => this.editor() === 'profile');
toggleEditor(type: EditorType) {
- this.editor = type;
+ this.editor.set(type);
}
}
diff --git a/adev/src/content/examples/reactive-forms/src/app/profile-editor/profile-editor.component.1.html b/adev/src/content/examples/reactive-forms/src/app/profile-editor/profile-editor.component.1.html
index 28d678f2631..cc00ded4317 100644
--- a/adev/src/content/examples/reactive-forms/src/app/profile-editor/profile-editor.component.1.html
+++ b/adev/src/content/examples/reactive-forms/src/app/profile-editor/profile-editor.component.1.html
@@ -30,7 +30,7 @@
Aliases
- @for(alias of aliases.controls; track alias.value; let i = $index) {
+ @for(alias of aliases.controls; track $index; let i = $index) {
diff --git a/adev/src/content/examples/reactive-forms/src/app/profile-editor/profile-editor.component.html b/adev/src/content/examples/reactive-forms/src/app/profile-editor/profile-editor.component.html
index 87f509ff9da..bc37bc68214 100644
--- a/adev/src/content/examples/reactive-forms/src/app/profile-editor/profile-editor.component.html
+++ b/adev/src/content/examples/reactive-forms/src/app/profile-editor/profile-editor.component.html
@@ -29,7 +29,7 @@
Aliases
- @for (alias of aliases.controls; track alias.value; let i = $index) {
+ @for (alias of aliases.controls; track $index; let i = $index) {
@@ -45,7 +45,7 @@
-
+
Form Value: {{ profileForm.value | json }}
diff --git a/adev/src/content/examples/reactive-forms/src/app/profile-editor/profile-editor.component.ts b/adev/src/content/examples/reactive-forms/src/app/profile-editor/profile-editor.component.ts
index fd68a0e4332..f29642fbb07 100644
--- a/adev/src/content/examples/reactive-forms/src/app/profile-editor/profile-editor.component.ts
+++ b/adev/src/content/examples/reactive-forms/src/app/profile-editor/profile-editor.component.ts
@@ -5,12 +5,13 @@ import {FormBuilder, ReactiveFormsModule} from '@angular/forms';
import {Validators} from '@angular/forms';
// #enddocregion validator-imports
import {FormArray} from '@angular/forms';
+import {JsonPipe} from '@angular/common';
@Component({
selector: 'app-profile-editor',
templateUrl: './profile-editor.component.html',
styleUrls: ['./profile-editor.component.css'],
- imports: [ReactiveFormsModule],
+ imports: [ReactiveFormsModule, JsonPipe],
})
export class ProfileEditorComponent {
private formBuilder = inject(FormBuilder);
diff --git a/adev/src/content/examples/structural-directives/src/app/app.component.html b/adev/src/content/examples/structural-directives/src/app/app.component.html
index 81380c34220..e02ce08a9af 100644
--- a/adev/src/content/examples/structural-directives/src/app/app.component.html
+++ b/adev/src/content/examples/structural-directives/src/app/app.component.html
@@ -210,12 +210,12 @@
-
+
IfLoadedDirective
-
+
TrigonometryDirective
diff --git a/adev/src/content/examples/testing/src/app/demo/demo.ts b/adev/src/content/examples/testing/src/app/demo/demo.ts
index 39f0cb6281e..d930d1ce1f4 100755
--- a/adev/src/content/examples/testing/src/app/demo/demo.ts
+++ b/adev/src/content/examples/testing/src/app/demo/demo.ts
@@ -420,25 +420,25 @@ export class ShellComponent {}
template: `
Specs Demo
-
+
Input/Output Component
-
+
External Template Component
-
+
Component With External Template Component
-
+
Reverse Pipe
-
+
InputValueBinder Directive
-
+
Button Component
-
+
Needs Content