multi: true is 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(like CustomInputComponent) and these functions are going to be called at a later point in time.
In the above snippet, there is no function declaration that uses the FormControlName class, it's just an object. If you were to simply use useExisting: FormControlName you'd get an error.
Thank you for the kind words!
multi: true
is 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
forwardRef
example can be seen here.In the above snippet, there is no function declaration that uses the
FormControlName
class, it's just an object. If you were to simply useuseExisting: FormControlName
you'd get an error.Here is a great article that explains
forwardRef
.Thanks for the clarification 👍