| 2189 | standalone: false, |
| 2190 | }) |
| 2191 | export class MyInput implements ControlValueAccessor { |
| 2192 | @Output('input') onInput = new EventEmitter(); |
| 2193 | value!: string; |
| 2194 | |
| 2195 | control: AbstractControl | null = null; |
| 2196 | |
| 2197 | constructor(public controlDir: NgControl) { |
| 2198 | controlDir.valueAccessor = this; |
| 2199 | } |
| 2200 | |
| 2201 | ngOnInit() { |
| 2202 | this.control = this.controlDir.control; |
| 2203 | } |
| 2204 | |
| 2205 | writeValue(value: any) { |
| 2206 | this.value = `!${value}!`; |
| 2207 | } |
| 2208 | |
| 2209 | registerOnChange(fn: (value: any) => void) { |
| 2210 | this.onInput.subscribe({next: fn}); |
| 2211 | } |
| 2212 | |
| 2213 | registerOnTouched(fn: any) {} |
| 2214 | |
| 2215 | dispatchChangeEvent() { |
| 2216 | this.onInput.emit(this.value.substring(1, this.value.length - 1)); |
| 2217 | } |
| 2218 | } |
| 2219 | |
| 2220 | @Component({ |
| 2221 | selector: 'my-input-form', |