简体   繁体   English

使用Angular2延迟加载“无法找到模块”

[英]'Cannot find module' with Angular2 lazy loading

Having trouble with implementing routing in combination with lazy loading. 与延迟加载一起实现路由时遇到问题。
My code can be found here: https://github.com/ahartvign/NetCoreDemos 我的代码可以在这里找到: https//github.com/ahartvign/NetCoreDemos

Whenever I try to navigate to my lazy loaded route 'tracking', I get the error: 每当我尝试导航到我的延迟加载路线'跟踪'时,我都会收到错误:
Cannot find module './trackers/trackers.module' 找不到模块'./trackers/trackers.module'

I've tried multiple different values for loadChildren: 我为loadChildren尝试了多个不同的值:

'trackers/trackers.module#TrackersModule'  
'./trackers/trackers.module#TrackersModule'  
'/trackers/trackers.module#TrackersModule' 

And all of the above with default export instead of #TrackersModule . 以上所有都使用默认导出而不是#TrackersModule

I've also tried restarting my server, as apparently some people have had problems with that. 我也尝试重新启动我的服务器,因为显然有些人遇到了问题。

Update : Add to your app.routing.ts 更新:添加到您的app.routing.ts

export const routing: ModuleWithProviders = RouterModule.forRoot(routes,
        {enableTracing :true , preloadingStrategy :PreloadAllModules }
 );  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM