We have created a
DynamicComponent and instances of it will be created dynamically (Not declaratively via markup) by other components. We need to understand how to include this component in our module.
Add the component to the modules
declarations: [ ... , DynamicComponent],
entryComponents: [..., DynamicComponent],
This way Angular production build will not prune the component due to the fact that it does not see it included in any of the templates. It will also generated a component factory for the
DynamicComponent such that it can be created by clients of the factory.
I put in a feature request with Angular to make this automatic. Ideally Angular would scan both our templates and the code base to figure out when we need
entryComponents and automatically include them: