import { Component, OnDestroy, OnInit } from '@angular/core'; import { FormControl } from '@angular/forms'; import { Subject, takeUntil } from 'rxjs'; @Component({ selector: 'mask-cypress-test-mask', styles: [ 'code { border: 1px solid #ddd; background-color: #eee; padding: 0 5px; border-radius: 3px; }', ], template: `
Mask: {{ mask }}
Form Value: {{ form.value }}
`, }) export class CypressTestTriggerOnMaskChangeComponent implements OnInit, OnDestroy { public mask: string = ''; public form: FormControl = new FormControl(''); public radio: FormControl = new FormControl('de'); private destroyed = new Subject(); public ngOnInit(): void { this.radio.valueChanges.pipe(takeUntil(this.destroyed)).subscribe((value) => { this.mask = value === 'de' ? '' : '00 000 00 00'; }); } public ngOnDestroy(): void { this.destroyed.next(); this.destroyed.complete(); } }