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

Class LegacyParsingInput

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

Source from the content-addressed store, hash-verified

1403 // --- 1. Component Setup ---
1404 // An FVC custom control designed for Signal Forms, used inside a legacy template-driven `ngModel`.
1405 @Component({
1406 selector: 'legacy-parsing-input',
1407 template: `<input #i [value]="rawValue()" (input)="rawValue.set(i.value)" />`,
1408 })
1409 class LegacyParsingInput {
1410 readonly value = model<number | null>(null);
1411 protected readonly rawValue = transformedValue(this.value, {
1412 parse: (val) => {
1413 if (val === '') return {value: null};
1414 const num = Number(val);
1415 if (Number.isNaN(num)) {
1416 return {error: {kind: 'parse', message: `${val} is not numeric`}};
1417 }
1418 return {value: num};
1419 },
1420 format: (val) => val?.toString() ?? '',
1421 });
1422 getRawValueSignal() {
1423 return this.rawValue;
1424 }
1425 }
1426
1427 @Component({
1428 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