简体   繁体   中英

How could I call forRoot method in loadChildren () => XPTOModule?

I have a Module Feature in NPM. I can load this module this way:

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { MyContentModule } from 'my-contentModule'

const routes: Routes = [
 { 
      path: 'my-path', 
      loadChildren: ()=> MyContentModule
    }
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }

The code above works. But I need pass a data configuration to my module in forRoot Method.

I try this unsuccessfully:

const routes: Routes = [
 { 
      path: 'my-path', 
      loadChildren: ()=> MyContentModule.forRoot({})
    }
];

What are the alternatives to this problem?

要保持注册,我可以这样传递数据:

MyContentModule.forRoot({}).ngModule

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM