Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Ivy is not liking the @Host() decorator #31539
I suspect you are experiencing the following known breaking change:
Strictly speaking, this is actually a bug fix compared to ViewEngine (VE). The reason is that in VE, the
Looking at your stacktrace, it looks like the component is dynamically created and inserted by the router. Therefore, no element exists that statically hosts your component, so the VE compiler did never actually apply the
The situation has changed with Ivy, as Ivy does in fact verify the
Note that for the above explanation to make sense, it is relevant to know that the injector used to dynamically create a component is considered a module injector, not an element injector, even if the injector does correspond with an element injector.
What I meant by dynamically inserted components is components that are instantiated by the router, in this case. So yes, the component itself can be AOT compiled, however this compiled component can be dynamically inserted during runtime using APIs such as ViewContainerRef and ComponentFactory. This is exactly what the router does: based on the current URL and your app's route table, it will figure out the corresponding component type and create an instance of it and insert it at
To understand the
Bottom line is that
I could only solve it, like this:
I could not use
Do you have a better solution?