You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NgControlStatus directive won't update with ChangeDetectionStrategy.OnPush #44976
Which @angular/* package(s) are the source of the bug?
forms
Is this a regression?
No
Description
[Component A]
[Component B (@input formControl: FormControl) <input required [formControl]='formControl'>]
Let's suppose you have a component A that pass a formControl to component, and call its setValue method at some point.
Without use onPush strategy, the value and the validation are correctly applied to the input element in the component B
But if you use onPush, the validation classes are not properly added/removed
Activity
dylhunn commentedon Feb 7, 2022
This is related to #10816
atscott commentedon Feb 7, 2022
Closing - this is working as expected. Angular change detection generally works off of references for inputs (some exceptions being
ngFor,ngClass, etc). TheFormControlinput did not change somy-testis not dirty. You need to subscribe to the relevantchangesof the control in yourmy-testand callmarkForCheckto mark the component dirty at the appropriate time: https://stackblitz.com/edit/angular-m6qbl9?file=src%2Fapp%2Fapp.component.htmlThis is true of any input across Angular and is not isolated to the forms package.
angular-automatic-lock-bot commentedon Mar 10, 2022
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.