I have two input controls in reactive form on the page (see sample). Both should be valid when content only 4 chars long. When I edit “hidden control” it fills other control (“PIN code”) with new masked value with following code:
pinControl.valueChanges.subscribe((value: string) => {
console.log(value);
this.pinVisibleControl.setValue(new Array(value.length).fill('*').join(''));
this.pinVisibleControl.markAsTouched({ onlySelf: true });
console.log(`PIN visible status: ${this.pinVisibleControl.status}`);
});
The problem is the validation state classes (ng-valid particularly) are applied to “PIN code” not right after change of control value, but only in next change cycle (when I enter fifth letter). So green valid indicator on “PIN code” appears only after next change (usually when it contains 3 or 5 letters).
Any suggestion how to apply validation classes right after value change?