2016-09-16 5 views
0

サンプルのangular2アプリケーションでフィーチャモジュールの遅延ロードを実装しようとしています。Angular2(RC-6)でレイジーロードモジュールを使用できません

私のアプリケーションにはルートモジュールと2つの機能モジュールがあります。

ルートモジュールのパスとファイルをルーティング私は遅延ロードを実装したい

app/public/scripts/app.module.ts 
app/public/scripts/app.routing.ts 

機能モジュールのパスと、それはルーティングです以下は

app/public/scripts/modules/user/app.user.module.ts 
app/public/scripts/modules/user/app.user.routing.ts 

されているapp.routing.tsコードです以下は

'use strict'; 

import {Routes , RouterModule } from '@angular/router'; 
import { ModuleWithProviders } from '@angular/core'; 

const appRoutes : Routes = [ 
{path: 'ausers' , loadChildren: 'scripts/modules/user/app.users.module#UsersModule' } 
]; 

export const appRoutingProviders: any[] = []; 

export const routing: ModuleWithProviders = RouterModule.forRoot(appRoutes); 

app.user.routing.tsコード

です
'use strict'; 

import { ModuleWithProviders } from '@angular/core'; 
import { Routes , RouterModule } from '@angular/router'; 

//-- import components , directives and pipes 
import { AppUsersComponent } from './app.users.component'; 


const UserRoutes :Routes = [ 
{path: 'ausers/showusers' , component: AppUsersComponent } 
] 

export const userRouting: ModuleWithProviers = RouterModule.forChild(UserRoutes); 

は、ユーザーはそれが私はモジュールのロードおよびバンドルのためのWebPACKを使用してい

Failed to parse SourceMap: http://localhost:3000/scripts/BehaviorSubject.js.map Angular 2 is running in the development mode. Call >enableProdMode() to enable the production mode. EXCEPTION: Uncaught (in promise): Error: SyntaxError: Unexpected >token < Evaluating http://localhost:3000/scripts/modules/user/app.users.module Error loading http://localhost:3000/scripts/modules/user/app.users.module

エラー

の下に表示されるアプリケーションにリンクの下に

routerLink = "ausers/showusers"

をクリックします。
このエラーの原因は何でしょうか?

+0

唯一のエラーメッセージはありますか?とにかく..子ルートは相対的なものなので、子ルートは 'ausers/showusers'から' showusers'に変更してください。 – mxii

+0

パスが変更されませんでした。問題のエラーに関する詳細情報を更新しました – refactor

+0

@ j2L4e、このリンクで提供したソリューションが機能しました。 – refactor

答えて

0

あなたはsrc/に、モジュールの相対パスを指定する必要があります。

{path: 'ausers' , loadChildren: 'app/public/scripts/modules/user/app.users.module#UsersModule' } 

はまた、遅延ロードは#11837とRC7で修正されましたRC6上のWebPACK、とバギーでした。

関連する問題