我有一個非常簡單的Angular2 RC5測試項目,它試圖使用路由到延遲加載模塊。我看不出這個項目有什麼問題。Angular2 RC5路由器無法找到模塊(延遲加載)
夾
app
|-about (contains about.module.ts and about.component.ts)
|-home (contains home.module.ts, home.component.ts)
app.routing.ts
export const routes: Routes = [
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: 'home', loadChildren: './app/home/home.module' },
{ path: 'about', loadChildren: './app/about/about.module' }
];
export const routing = RouterModule.forRoot(routes);
home.module.ts
import { NgModule } from '@angular/core';
import { HomeComponent } from './home.component';
@NgModule({
declarations: [HomeComponent],
exports: [HomeComponent]
})
export default class HomeModule { }
個home.component.ts
import { Component } from '@angular/core';
@Component({
template: `<h2>Home...</h2>`
})
export class HomeComponent { }
我知道重定向到「家」的工作,在啓動時,我可以看到home.module.js和home.component.js文件下載,但隨後拋出控制檯錯誤消息Cannot find 'HomeModule' in './app/home/home.module'
(而在網絡流量選項卡我可以證實,這兩個js文件是正確的,拼寫是否正確等)
我想我還應該提及我使用的是路由器3.0.0-rc.1,這是Angular2 RC5的最新版本,據我所知。 – McGuireV10