Try to search your question here, if you can't find : Ask Any Question Now ?

route to path in a lazy loaded module and that is shown in named router outlet

HomeCategory: stackoverflowroute to path in a lazy loaded module and that is shown in named router outlet
Avatarwillson asked 1 week ago

There are two modules app and lazy modules. Need do display a component lazily as a part of lazy module and in a named router outlet.

Main Module – app
Lazily loaded module – lazy
secondary outlet in lazy module -> modal
Component needed – clear

Navigation:

 this.router.navigate([{outlets:{primary:'lazy', modal:'clear'}}]);

App Module:

const routes: Routes = [
    {
      path: 'lazy',
      loadChildren: './lazy.module#LazyModule'
    }
  ]

  @NgModule({
    declarations: [],
    imports: [
      RouterModule.forRoot(routes)
    ],
    bootstrap: [AppComponent]
  })
  export class AppModule { }

Lazy Module:

const routes: Routes = [
        {
          path: 'clear',
          component: 'ClearComponent'
        }
  ]

  @NgModule({
    declarations: [clearComponent],
    imports: [
      RouterModule.forChild(routes)
    ]
  })
  export class LazyModule{ }

This doesn’t work and the error is ->
Error: Cannot match any routes. URL Segment: ‘clear’

1 Answers
Best Answer
AvatarMannu answered 1 week ago
Your Answer

19 + 8 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com