1

I am trying to lazy load a module while also sending along a parameter.

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

basically I would like to lazy load this module while send a parameter like: venuedetail/40 <- this number represents an ID.

Here is the module I am lazy loading:

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 { }

and here is the route config for the lazy loaded module.

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);

The url changes to venuedetail/40 , but the component never initializes.

David Aguirre
  • 1,382
  • 4
  • 15
  • 29
  • What problems do you have? What is your question? What is the expected behaviour, what is the actual behaviour? Do you have any errors in your console? – Patrick Jan 31 '17 at 22:12
  • The path updates in the URL, but it does not initialize the component. There are no errors in the console. Also, once the module is loaded, I expect to navigate to the component listed in the router config for the lazy loaded module with the passed parameter – David Aguirre Jan 31 '17 at 22:13

0 Answers0