Skip to content

Commit 0d26130

Browse files
erkamyamanalxhub
authored andcommitted
docs: invoke signal inputs in adev examples and tutorials
Several adev example and tutorial files read a signal input as a bare reference (this.foo) instead of invoking it (this.foo()). Because an InputSignal is a function object, the bare reference is always truthy and never yields the underlying value, so the surrounding guard or binding silently did the wrong thing: - animations open-close(.1/.3): the `!this.logging` guard in onAnimationEvent was always false, so the early return never fired. - form-validation forbidden-name.directive: the `this.forbiddenName` ternary condition was always truthy, so validation ran even when no forbidden name was configured. - first-app steps 12 and 14 housing-location: `housingLocation.photo` read `.photo` off the signal function (undefined), leaving the listing image src empty. Invoke the signals so the examples reflect correct signal-input usage.
1 parent 59f6ef6 commit 0d26130

6 files changed

Lines changed: 6 additions & 6 deletions

File tree

‎adev/src/content/examples/animations/src/app/open-close.1.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class OpenCloseKeyframeComponent {
5757

5858
logging = input(false);
5959
onAnimationEvent(event: AnimationEvent) {
60-
if (!this.logging) {
60+
if (!this.logging()) {
6161
return;
6262
}
6363
}

‎adev/src/content/examples/animations/src/app/open-close.3.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class OpenCloseBooleanComponent {
3333

3434
logging = input(false);
3535
onAnimationEvent(event: AnimationEvent) {
36-
if (!this.logging) {
36+
if (!this.logging()) {
3737
return;
3838
}
3939
}

‎adev/src/content/examples/animations/src/app/open-close.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class OpenClose {
7070
// #docregion events1, events
7171
onAnimationEvent(event: AnimationEvent) {
7272
// #enddocregion events1, events
73-
if (!this.logging) {
73+
if (!this.logging()) {
7474
return;
7575
}
7676
// #docregion events

‎adev/src/content/examples/form-validation/src/app/shared/forbidden-name.directive.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class ForbiddenValidatorDirective implements Validator {
3434
readonly forbiddenName = input<string>('', {alias: 'appForbiddenName'});
3535

3636
validate(control: AbstractControl): ValidationErrors | null {
37-
return this.forbiddenName
37+
return this.forbiddenName()
3838
? forbiddenNameValidator(new RegExp(this.forbiddenName(), 'i'))(control)
3939
: null;
4040
}

‎adev/src/content/tutorials/first-app/steps/12-forms/src/app/housing-location/housing-location.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {RouterLink} from '@angular/router';
99
<section class="listing">
1010
<img
1111
class="listing-photo"
12-
[src]="housingLocation.photo"
12+
[src]="housingLocation().photo"
1313
alt="Exterior photo of {{ housingLocation().name }}"
1414
crossorigin
1515
/>

‎adev/src/content/tutorials/first-app/steps/14-http/src-final/app/housing-location/housing-location.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {RouterLink} from '@angular/router';
99
<section class="listing">
1010
<img
1111
class="listing-photo"
12-
[src]="housingLocation.photo"
12+
[src]="housingLocation().photo"
1313
alt="Exterior photo of {{ housingLocation().name }}"
1414
crossorigin
1515
/>

0 commit comments

Comments
 (0)