MCPcopy Create free account
hub / github.com/angular/angular / LegacyParsingInput

Class LegacyParsingInput

packages/forms/signals/test/web/interop.spec.ts:1438–1458  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1436 // --- 1. Component Setup ---
1437 // An FVC custom control designed for Signal Forms, used inside a legacy template-driven `ngModel`.
1438 @Component({
1439 selector: 'legacy-parsing-input',
1440 template: `<input #i [value]="rawValue()" (input)="rawValue.set(i.value)" />`,
1441 })
1442 class LegacyParsingInput {
1443 readonly value = model<number | null>(null);
1444 protected readonly rawValue = transformedValue(this.value, {
1445 parse: (val) => {
1446 if (val === '') return {value: null};
1447 const num = Number(val);
1448 if (Number.isNaN(num)) {
1449 return {error: {kind: 'parse', message: `${val} is not numeric`}};
1450 }
1451 return {value: num};
1452 },
1453 format: (val) => val?.toString() ?? '',
1454 });
1455 getRawValueSignal() {
1456 return this.rawValue;
1457 }
1458 }
1459
1460 @Component({
1461 template: `<legacy-parsing-input [(ngModel)]="val" #model="ngModel" />`,

Callers

nothing calls this directly

Calls 3

ComponentInterface · 0.90
transformedValueFunction · 0.90
toStringMethod · 0.65

Tested by

no test coverage detected