statusChanges is not fired upon dynamic validation added with NG_VALIDATOR
See original GitHub issueπ bug report
Affected Package
The issue is caused by package @angular/formsIs this a regression?
Probably not
Description
You can create directives that provide NG_VALIDATOR token so additional validation can be applied. Simple case, I have a checkbox that hides a particular field. If the field is enabled, I want it to be required. I can do this with built-in required
directive. When I toggle my field, form becomes invalid because it is empty and required. However statusChanges
stream does not fire to let me know that form became INVALID
π¬ Minimal Reproduction
https://stackblitz.com/edit/angular-ng-validator-bug
π Your Environment
Angular Version:
10.0.1
Anything else relevant? Watch out for ExpressionChanged error, form does actually become invalid the moment directive with NG_VALIDATOR is instantiated but the binding does not update. Thatβs how I actually got to use statusChanges stream and noticed itβs not firing.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (6 by maintainers)
Top GitHub Comments
Got it, thanks for the quick reply. In case itβs helpful, hereβs the actual case where I ran into this: https://stackblitz.com/edit/angular-declarative-dynamic-validation?file=src%2Fapp%2Fvalidator%2Fvalidator.directive.ts&s=09
I was investigating declarative approaches to dynamic validation, as opposed to imperative
setValidators
calls. Since itβs dynamic I had to call validation manually anyway, so itβs not blocking, but still rather strange behaviour.This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.