Found the way to handle Auxiliary router for lazy loading moudle and erge load module are different.

In Erge loading, it is recommended to create a shell component, inside shell component you need to define the router-outlet for each Auxiliary routes and primary route.

const routes: Routes = [
...
{ path: 'speakers', component: SpeakersComponent, children: [
{ path: 'speakersList', component: SpeakersListComponent, outlet: 'list' },
{ path: ':id', component: BioComponent, outlet: 'bio' }
] },
];

For example, in the code above, 'SpeakersComponent' is shell component.

<div class="columns">
<md-card>
<router-outlet name="list"></router-outlet>
</md-card>
<md-card>
<router-outlet name="bio"></router-outlet>
</md-card>
</div>

Inside the html, it defines all the auxilliary routes for shell component.


But the story changes when you use lazy loading...

For example, we lazy load a feature module inside our root routes configuration:

  {
path: 'preview',
loadChildren: 'app/preview/preview.module'
},

And here is the feature module routes:

const routes = [
{
path: '',
component: PreviewLeftComponent
},
{
path: ':id',
component: PokemonDetailComponent
},
{
path: ':id',
outlet:'aux',
component: PreviewDetailComponent
}
];

There is one auxiliary route. But here we didn't use any shell component.

This is because I found, when using lazy loading, Angular doesn't goes into Shell component html to find auxiliary routes' router-outlet, it goes to root component,

So we have to define the auxiliary route outlet inside root component:

<!-- aoo.component.html -->

<md-sidenav-layout>
<md-sidenav align="start" mode="side" opened>
<app-sidenav></app-sidenav>
</md-sidenav>
<div class="main-content">
<router-outlet></router-outlet>
</div>
<md-sidenav align="end" mode="side" [opened]="curtPath === 'preview'">
<router-outlet name="aux"></router-outlet>
</md-sidenav>
</md-sidenav-layout>

Github, Talk

[Angular Router] Lazy loading Module with Auxiliary router的更多相关文章

  1. [Angular 8] Lazy loading with dynamic loading syntax

    @NgModule({ declarations: [AppComponent, HomeComponent], imports: [ BrowserModule, MatSidenavModule, ...

  2. [Angular2 Router] Lazy Load Angular 2 Modules with the Router

    Angular 2 lazy loading is a core feature of Angular 2. Lazy loading allows your application to start ...

  3. [AngularJS] Lazy loading Angular modules with ocLazyLoad

    With the ocLazyLoad you can load AngularJS modules on demand. This is very handy for runtime loading ...

  4. [Angular] Show a Loading Indicator for Lazy Routes in Angular

    We can easily code split and lazy load a route in Angular. However when the user then clicks that la ...

  5. [AngularJS] Lazy Loading modules with ui-router and ocLazyLoad

    We've looked at lazy loading with ocLazyLoad previously, but what if we are using ui-router and want ...

  6. Angular2+typescript+webpack2(支持aot, tree shaking, lazy loading)

    概述 Angular2官方推荐的应该是使用systemjs加载, 但是当我使用到它的tree shaking的时候,发现如果使用systemjs+rollup,只能打包成一个文件,然后lazy loa ...

  7. Lazyr.js – 延迟加载图片(Lazy Loading)

    Lazyr.js 是一个小的.快速的.现代的.相互间无依赖的图片延迟加载库.通过延迟加载图片,让图片出现在(或接近))视窗才加载来提高页面打开速度.这个库通过保持最少选项并最大化速度. 在线演示    ...

  8. Can you explain Lazy Loading?

    Introduction Lazy loading is a concept where we delay the loading of the object until the point wher ...

  9. iOS swift lazy loading

    Why bother lazy loading and purging pages, you ask? Well, in this example, it won't matter too much ...

随机推荐

  1. python绘图问题

    论文绘图整理 # coding: utf-8 #来源:https://blog.csdn.net/A_Z666666/article/details/81165123 import matplotli ...

  2. Codeforces 451 E. Devu and Flowers(组合数学,数论,容斥原理)

    传送门 解题思路: 假如只有 s 束花束并且不考虑 f ,那么根据隔板法的可重复的情况时,这里的答案就是 假如说只有一个 f 受到限制,其不合法时一定是取了超过 f 的花束 那么根据组合数,我们仍然可 ...

  3. Spring入门--控制反转(IOC)与依赖注入(DI)

        1.控制反转(Inversion of Control)与依赖注入(Dependency Injection) 控制反转即IoC (Inversion of Control).它把传统上由程序 ...

  4. C8815 用 USB网卡(Asix AX88772 )上网

    C8815 用 USB网卡(Asix AX88772 )上网 C8815不支持给USB外设供电,不过可以使用自供电的OTG线带动USB设备 C8815最新固件中没有Asix AX88772驱动,需要自 ...

  5. windows 批处理脚本(batch scripting)

    Guide to Windows Batch Scripting DOS 不需对变量事先声明.未声明或未初始化变量是一个空字符串("") 1. 变量赋值 set命令用于变量赋值.s ...

  6. Android SocketService

    package com.freer.infusion.module.service; import android.app.ActivityManager; import android.app.Pe ...

  7. sql server备份与还原 sql语句

    USE master DECLARE tb CURSOR LOCAL FOR SELECT 'Kill '+ CAST(Spid AS VARCHAR) FROM master.dbo.sysproc ...

  8. request.getRemoteUser() Spring Security做权限控制后

    一. request.getRemoteUser();//获取当前缓存的用户,比如Spring Security做权限控制后就会将用户登录名缓存到这里 request.getRemoteAddr(); ...

  9. Rick's RoTs -- Rules of Thumb for MySQL--转载

    原文地址:http://mysql.rjweb.org/doc.php/ricksrots Brought to you by Rick James Here are 160+ tips, trick ...

  10. Hadoop3.0配置

    1.core-site.xml <configuration> <property> <name>fs.default.namenode</name> ...