MCPcopy
hub / github.com/angular/angular / LegacyControlWithValidators

Class LegacyControlWithValidators

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

Source from the content-addressed store, hash-verified

181 const legacyErrors = signal<ValidationErrors | null>(null);
182
183 @Component({
184 selector: 'legacy-control-with-validators',
185 template: `<input [value]="value" (input)="onInput($event.target.value)" />`,
186 providers: [
187 {provide: NG_VALUE_ACCESSOR, useExisting: LegacyControlWithValidators, multi: true},
188 {provide: NG_VALIDATORS, useExisting: LegacyControlWithValidators, multi: true},
189 ],
190 })
191 class LegacyControlWithValidators implements ControlValueAccessor, Validator {
192 value = '';
193
194 private onChangeFn?: (value: string) => void;
195
196 writeValue(newValue: string): void {
197 this.value = newValue;
198 }
199
200 registerOnChange(fn: (value: string) => void): void {
201 this.onChangeFn = fn;
202 }
203
204 registerOnTouched(fn: () => void): void {}
205
206 validate(control: AbstractControl): ValidationErrors | null {
207 return legacyErrors();
208 }
209
210 onInput(newValue: string) {
211 this.value = newValue;
212 this.onChangeFn?.(newValue);
213 }
214 }
215
216 @Component({
217 imports: [LegacyControlWithValidators, FormField],

Callers

nothing calls this directly

Calls 1

ComponentInterface · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…