Angular 2可以延迟发送参数时加载模块?

时间:2017-01-31 22:09:21

标签: angular angular2-routing angular2-modules

我正在尝试延迟加载模块,同时还发送参数。

{  
    path: 'venuedetail',
    loadChildren: () => System.import('../containers/venue-detail/venue-detail.module').then((file: any) => {
        return file.default;
    })
},

基本上我想延迟加载这个模块,同时发送一个参数,如:venuedetail / 40< - 这个数字代表一个ID。

这是我懒加载的模块:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule } from '@angular/router'; 

import { VenueDetailRouterModule } from './venue-detail.routes';
import { VenueDetailComponent } from './venue-detail.component';
import { VenueDetailService } from '../../shared/http/venue-detail/venue-detail.service';



@NgModule({
    imports: [
        CommonModule,
        VenueDetailRouterModule
    ],
    declarations: [
        VenueDetailComponent
    ],
    providers: [VenueDetailService],
    exports: [RouterModule]
    })
export default class VenueDetailModule { }

这是延迟加载模块的路由配置。

import { Routes, RouterModule } from '@angular/router';
import { VenueDetailComponent } from 'app-containers';

let VENUEDETAILROUTES: Routes = [{
     path: '',
    component: VenueDetailComponent,
        children: [

            {
                path: ':id',
                component: VenueDetailComponent
            }

        ]
}];

export let VenueDetailRouterModule = RouterModule.forChild(VENUEDETAILROUTES);

url更改为venuedetail / 40,但组件从未初始化。

0 个答案:

没有答案