问题描述
我正在尝试在我的应用程序中实现RC5更改,并且在我的路由中延迟加载模块时遇到了一些麻烦.
I'm trying to implement RC5 changes in my app and I'm getting some trouble when lazy loading modules in my routing.
这是我应用程序中受影响文件的结构:
This is the structure in my app for the affected files:
/app
/components/meda/meda.module.ts
/components/meda/meda.routing.ts
app.routing.ts
这是我的app.routing.ts
And this is my app.routing.ts
const routes: Routes = [
{
path: '',
redirectTo: 'init',
pathMatch: 'full'
},
{
path: 'init',
loadChildren: './components/init/init.module#InitModule'
},
{
path: 'meda',
loadChildren: './components/meda/meda.module#MedaModule'
}
];
和我的meda.module.ts
and my meda.module.ts
@NgModule({
imports: [ routing ],
})
export class MedaModule { }
我的应用程序可以很好地加载到init路由中,因为引导程序会加载InitModule,但是一旦我尝试导航到meda,我就会得到以下信息
My application loads fine into the init route because bootstrap loads InitModule, but once I try to navigate to meda I get the following
GET http://localhost/web/components/meda/meda.module 404 (Not Found)
似乎找不到模块位置.我也尝试过
It seems it can't find the module location. I also tried with
loadChildren: 'app/components/meda/meda.module#MedaModule'
但没有运气;知道我在做什么错吗?
but no luck; any idea what I'm doing wrong?
谢谢
推荐答案
在不加引号的情况下编写路径.或./或/
Write the path without leading . or ./ or /
loadChildren: 'components/init/init.module#InitModule'
地址的起点是您的html文件的位置.
The start point of address is the location of your html file.
这篇关于Angular2 RC5延迟加载路由找不到模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!