-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NgModel defers writeValue call to the next tick. Conflicts with OnInit's contract of child components. #13568
Comments
Not sure but I think it's done to avoid |
Hi @DzmitryShylovich
I'm still wondering whether the particular case described in this issue can be addressed? Or at least maybe described as a caveat somewhere in Angular's documentation. Thank you, |
Recently i saw related issue when using |
Any idea when this will be fixed? |
@jelbourn, this is really broken for custom value accessors, because it introduces difference between ngModel input and any other input: <input [ngModel]="value" [data]="data">
|
I'm submitting a ... (check one with "x")
Current behavior
NgModel defers calling writeValue of the ControlValueAccessor with the supplied value to the next tick.
While OnInit's documentation states
As a result of the two things described above, it is not obvious, how to from a component implementing
ControlValueAccessor
supply values to inner components that expect their data-bound properties to be initialized inonInit
.Expected behavior
ngModel
's behavior?Minimal reproduction of the problem with instructions
The minimal plunker to reproduce
What is the motivation / use case for changing the behavior?
I am trying to place a color picker on a form. To do this I created a wrapper component that implements
ControlValueAccessor
which uses angular2-color-picker underneath.The wrapper's
_value
is set inwriteValue
and the wrapper is bound usingngModel
. The wrapper, in turn, has the following in its markup:The problem is
angular2-color-picker
tries to access its data-bound inputs inonInit
which triggers a bug down the road.color-picker.directive.ts
Please tell us about your environment:
Angular version: 2.3.0
Browser: all
Language: TypeScript
The text was updated successfully, but these errors were encountered: