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

Class LegacyParsingInput

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

Source from the content-addressed store, hash-verified

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