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

Class MyInput

packages/forms/test/value_accessor_integration_spec.ts:2132–2161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2130 template: '',
2131})
2132export class MyInput implements ControlValueAccessor {
2133 @Output('input') onInput = new EventEmitter();
2134 value!: string;
2135
2136 control: AbstractControl | null = null;
2137
2138 controlDir = inject(NgControl);
2139
2140 constructor() {
2141 this.controlDir.valueAccessor = this;
2142 }
2143
2144 ngOnInit() {
2145 this.control = this.controlDir.control;
2146 }
2147
2148 writeValue(value: any) {
2149 this.value = `!${value}!`;
2150 }
2151
2152 registerOnChange(fn: (value: any) => void) {
2153 this.onInput.subscribe({next: fn});
2154 }
2155
2156 registerOnTouched(fn: any) {}
2157
2158 dispatchChangeEvent() {
2159 this.onInput.emit(this.value.substring(1, this.value.length - 1));
2160 }
2161}
2162
2163@Component({
2164 template: ` <div [formGroup]="form">

Callers

nothing calls this directly

Calls 2

OutputInterface · 0.90
injectFunction · 0.90

Tested by

no test coverage detected