Upon receiving routing configuration from a server and loading it before the application bootstrap, the config.json
file contains the following setup:
[{
"path": "dashboard",
"component": "SingleComponent",
"data": {...}
},
{
"path": "payment",
"roles": ["normal-user"],
"children": [{
"path": "new",
"component": "SingleComponent",
"data": {...}
}
}]
}
where the "SingleComponent"
is replaced with the class reference before executing
router.resetConfig(loadedRoutes);
. Everything seems to be working fine, as loading /dashboard
displays the page correctly. However, I had to include the component reference in @NgModule.entryComponents
since there is no other reference to that component elsewhere.
Upon navigating to /payment/new
, an error occurs:
ERROR Error: Uncaught (in promise): Error: No component factory found for SingleComponent. Did you add it to @NgModule.entryComponents?
Error: No component factory found for SingleComponent. Did you add it to @NgModule.entryComponents?
at noComponentFactoryError (core.js:3898)
at CodegenComponentFactoryResolver.resolveComponentFactory (core.js:3962)
at RouterOutlet.activateWith (router.js:6652)
at ActivateRoutes.activateRoutes (router.js:5735)
at eval (router.js:5675)
at Array.forEach (<anonymous>)
at ActivateRoutes.activateChildRoutes (router.js:5674)
at ActivateRoutes.activateRoutes (router.js:5742)
at eval (router.js:5675)
at Array.forEach (<anonymous>)
at noComponentFactoryError (core.js:3898)
at CodegenComponentFactoryResolver.resolveComponentFactory (core.js:3962)
at RouterOutlet.activateWith (router.js:6652)
at ActivateRoutes.activateRoutes (router.js:5735)
at eval (router.js:5675)
at Array.forEach (<anonymous>)
at ActivateRoutes.activateChildRoutes (router.js:5674)
at ActivateRoutes.activateRoutes (router.js:5742)
at eval (router.js:5675)
at Array.forEach (<anonymous>)
at resolvePromise (zone.js:824)
at resolvePromise (zone.js:795)
at eval (zone.js:873)
at ZoneDelegate.invokeTask (zone.js:425)
at Object.onInvokeTask (core.js:4744)
at ZoneDelegate.invokeTask (zone.js:424)
at Zone.runTask (zone.js:192)
at drainMicroTaskQueue (zone.js:602)
at ZoneTask.invokeTask [as invoke] (zone.js:503)
at invokeTask (zone.js:1540)
However, looking at my module, it includes:
...
entryComponents: [ // components used by remote loaded routes
SingleComponent,
],
})
What could be causing this issue? Any suggestions or insights would be appreciated as there seems to be no documentation regarding this particular error.
The version of Angular being used is 5.0.0