After delving into the @angular/forms package I've been able to get a better understanding of how things really work under the hood. In this articl...
For further actions, you may consider blocking this person and/or reporting abuse
👍 I think that this is THE MORE DETAILED article I've ever read on @angular Forms!
KUDOS for the awesome work @anduser96
PS: maybe I've spotted a little error in the first sample of custom ControlValueAccessor I believe that the provider must call forwardRef to point to CustomInputComponent + use multi: true
Thank you for the kind words!
multi: trueis indeed required, I always forget about it.. :)Thanks for pointing it out! I'll update the article.
If the provider object is provided in the decorator, there is no need for
forwardRef. That's because decorators under the hood are functions and you can reference objects that have not been declared before(likeCustomInputComponent) and these functions are going to be called at a later point in time.Here's a TS playground.
A
forwardRefexample can be seen here.In the above snippet, there is no function declaration that uses the
FormControlNameclass, it's just an object. If you were to simply useuseExisting: FormControlNameyou'd get an error.Here is a great article that explains
forwardRef.Thanks for the clarification 👍
👍👍 wow - that's a ton of in-depth writing. Stuff like this really helps the community. Thanks!
Wow, thanks a lot for this in-depth information!! 👏👏
Woah, impressive!
Thank you! I wrote other articles on Angular and its ecosystem at indepth.dev. There are also other smart and passionate people who write there.
For sure! Thanks for all the writings, keep it up 🤓
Thank you so much for this!
Very cool, thanks for the article!