I've been trying to switch my app over to AoT compilation and have been getting this error in the production environment when the app is loading (it works fine locally).
Error: Can't resolve all parameters for IconService: (?, ?)
it seems like the error is coming from on the modules that is providing the IconService. The icons services constructor looks like
constructor(private http:Http, private iconConfiguror:IconConfiguror) {
So my question is what does this error mean and why would it happen in the prod environment only (I've tried enabling prod mode locally)?
It seems like it means that the http and icon configuration parameters aren't provided, but the icon config is provided at the app module level and the HttpModule
is imported in the IconModule
where the IconService
is provided.
@NgModule({
imports: [
CommonModule,
HttpModule,
],
declarations: [
IconComponent,
],
exports: [
IconComponent,
],
providers: [
IconService,
__platform_browser_private__.BROWSER_SANITIZATION_PROVIDERS,
],
})
And the barrel for our icon component.
export * from "./components/icon/icon.configuror";
export * from "./components/icon/icon.service.provider";
export * from "./components/icon/icon.service";
export * from "./components/icon/icon.component";
export * from "./components/icon/icon.module";
Fixed this by providing the IconService in a different way.
{
provide: IconService,
useFactory: iconServiceFactory,
deps: [Http, IconConfiguror],
},
and the factory itself
export function iconServiceFactory(http: Http, iconConfiguror: IconConfiguror) {
return new IconService(http, iconConfiguror);
}
I guess for some reason the Http wasn't being provided (even though HttpModule was imported) so I had to declare it as a dependency.
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