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

Class LegacyParsingInput

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

Source from the content-addressed store, hash-verified

1349 // --- 1. Component Setup ---
1350 // An FVC custom control designed for Signal Forms, used inside a legacy template-driven `ngModel`.
1351 @Component({
1352 selector: 'legacy-parsing-input',
1353 template: `<input #i [value]="rawValue()" (input)="rawValue.set(i.value)" />`,
1354 })
1355 class LegacyParsingInput {
1356 readonly value = model<number | null>(null);
1357 protected readonly rawValue = transformedValue(this.value, {
1358 parse: (val) => {
1359 if (val === '') return {value: null};
1360 const num = Number(val);
1361 if (Number.isNaN(num)) {
1362 return {error: {kind: 'parse', message: `${val} is not numeric`}};
1363 }
1364 return {value: num};
1365 },
1366 format: (val) => val?.toString() ?? '',
1367 });
1368 getRawValueSignal() {
1369 return this.rawValue;
1370 }
1371 }
1372
1373 @Component({
1374 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