angular 2异步路由模块+ entryComponents

时间:2017-04-18 15:28:31

标签: angular2-routing

我有一个异步加载模块,在角度为2时具有async route functionallity。在主模块中,我有一个实现,它使用组件工厂来实例化我使用entryComponents添加到异步模块的组件。

当我现在尝试实例化它时,我收到以下错误:

Error: No component factory found for InEntryComponentsComponent. Did you add it to @NgModule.entryComponents?
    at NoComponentFactoryError.ZoneAwareError (http://localhost:3000/polyfills.dll.js:4731:33)
    at NoComponentFactoryError.BaseError [as constructor] (http://localhost:3000/vendor.dll.js:28595:16)
    at new NoComponentFactoryError (http://localhost:3000/vendor.dll.js:28716:16)
    at _NullComponentFactoryResolver.resolveComponentFactory (http://localhost:3000/vendor.dll.js:28733:15)
    at AppModuleInjector.CodegenComponentFactoryResolver.resolveComponentFactory (http://localhost:3000/vendor.dll.js:28777:35)
    at SwapComponentDirective.set [as swapCmp] (http://localhost:3000/main.bundle.js:2959:66)
    at Wrapper_SwapComponentDirective.check_swapCmp (/ModalModule/SwapComponentDirective/wrapper.ngfactory.js:50:26)
    at View_ModalOverlay2.detectChangesInternal (/ModalModule/ModalOverlay/component.ngfactory.js:83:36)
    at View_ModalOverlay2.AppView.detectChanges (http://localhost:3000/vendor.dll.js:79810:14)
    at View_ModalOverlay2.DebugAppView.detectChanges (http://localhost:3000/vendor.dll.js:80005:44)
    at ViewContainer.detectChangesInNestedViews (http://localhost:3000/vendor.dll.js:80143:37)
    at CompiledTemplate.proxyViewClass.View_ModalOverlay_Host0.detectChangesInternal (/ModalModule/ModalOverlay/host.ngfactory.js:32:14)
    at CompiledTemplate.proxyViewClass.AppView.detectChanges (http://localhost:3000/vendor.dll.js:79810:14)
    at CompiledTemplate.proxyViewClass.DebugAppView.detectChanges (http://localhost:3000/vendor.dll.js:80005:44)
    at ViewContainer.detectChangesInNestedViews (http://localhost:3000/vendor.dll.js:80143:37)
    at CompiledTemplate.proxyViewClass.View_AppComponent_Host0.detectChangesInternal (/AppModule/AppComponent/host.ngfactory.js:31:14)
    at CompiledTemplate.proxyViewClass.AppView.detectChanges (http://localhost:3000/vendor.dll.js:79810:14)
    at CompiledTemplate.proxyViewClass.DebugAppView.detectChanges (http://localhost:3000/vendor.dll.js:80005:44)
    at ViewRef_.detectChanges (http://localhost:3000/vendor.dll.js:59572:20)
    at http://localhost:3000/vendor.dll.js:40308:67
    at Array.forEach (native)
    at ApplicationRef_.tick (http://localhost:3000/vendor.dll.js:40308:25)
    at http://localhost:3000/vendor.dll.js:40227:105
    at ZoneDelegate.invoke (http://localhost:3000/polyfills.dll.js:4162:26)
    at Object.onInvoke (http://localhost:3000/vendor.dll.js:30260:37)
    at ZoneDelegate.invoke (http://localhost:3000/polyfills.dll.js:4161:32)
    at Zone.run (http://localhost:3000/polyfills.dll.js:4033:43)
    at NgZone.run (http://localhost:3000/vendor.dll.js:30129:62)
    at Object.next (http://localhost:3000/vendor.dll.js:40227:81)
    at SafeSubscriber.schedulerFn [as _next] (http://localhost:3000/vendor.dll.js:42094:52)
    at SafeSubscriber.__tryOrUnsub (http://localhost:3000/vendor.dll.js:591:16)
    at SafeSubscriber.next (http://localhost:3000/vendor.dll.js:540:22)
    at Subscriber._next (http://localhost:3000/vendor.dll.js:493:26)
    at Subscriber.next (http://localhost:3000/vendor.dll.js:457:18)
    at EventEmitter.Subject.next (http://localhost:3000/vendor.dll.js:4237:25)
    at EventEmitter.emit (http://localhost:3000/vendor.dll.js:42080:76)
    at NgZone.checkStable (http://localhost:3000/vendor.dll.js:30225:40)
    at NgZone.onLeave (http://localhost:3000/vendor.dll.js:30301:14)
    at Object.onInvokeTask (http://localhost:3000/vendor.dll.js:30254:27)
    at ZoneDelegate.invokeTask (http://localhost:3000/polyfills.dll.js:4194:40)
    at Zone.runTask (http://localhost:3000/polyfills.dll.js:4071:47)
    at HTMLButtonElement.ZoneTask.invoke (http://localhost:3000/polyfills.dll.js:4265:33)

任何人都知道如何让这个运行?当我将组件移动到非异步加载的模块时,一切都很好。

作为基础,我正在使用angular2-webpack-starter。

0 个答案:

没有答案