import { SpinnerComponent, ExternalLibrary } from 'external.library'
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule, ExternalLibrary
],
bootstrap: [AppComponent]
, entryComponents: [SpinnerComponent]
})
Above is my code to specify entryComponent to a module. also this SpinnerComponent is from an external module which is ExternalModule.
Webpack giving error:
ERROR in SpinnerComponent cannot be used as an entry component.
Is belonging to the same module a requirement for a component to appear in entryComponents property list?
As far as I can go through the official definitions there is no such pre requisite specified for a component before appearing in entryComponent property.
An entry component is any component that Angular loads imperatively, (which means you're not referencing it in the template), by type. You specify an entry component by bootstrapping it in an NgModule, or including it in a routing definition.
Routed entryComponent: This sort of components are declared components and are added as an array inside the declarations section of the app. But, you may need to reference to a component by its class. Router components are not specified explicitly in the HTML of a component but, are registered in routes array.
The angular. module is the entry point of Angular applications. Each application has just one module that gets the rootElement <html> or <body> tag.
Components are the most basic UI building block of an Angular app. An Angular app contains a tree of Angular components. Angular components are a subset of directives, always associated with a template. Unlike other directives, only one component can be instantiated for a given element in a template.
I was having the same issue. What fixed it for me was adding the component to the entryComponents
of a module in my external library.
In your case that would mean updating the ExternalLibrary
NgModule to include SpinnerComponent
as an entry component instead of the app that's using the library.
@NgModule({
...
entryComponents: [SpinnerComponent]
...
})
export class ExternalLibrary { }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With