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. android图像处理系列之五--给图片添加边框(中)

    前面一篇讲到给图片加边框的方式,只能给图片加一些有规则的边框,如果想加一些比较精美的效果,就有点麻烦了.下面就给出解决这个问题的思路. 思路是:一些比较精美的花边图片我们是很难用代码控制,就目前本人水 ...

  2. node --进行后台的环境搭建

    1.下载winscp  --- 输入IP 端口 账号 密码  进入当前的服务器环境 2.下载xshell5 ---- 输入IP 端口  和 winscp 达成连接. 3.把本地代码放置 winscp远 ...

  3. 如何应对DDOS网络攻击(之二)

    上期回顾: 如何应对DDOS网络攻击(一) http://chenguang.blog.51cto.com/350944/302531   如何应对DDOS网络攻击(之二) 650) this.wid ...

  4. [转]Accept-Encoding

    原文地址:https://blog.csdn.net/sqzhao/article/details/49499471 HTTP Header中Accept-Encoding 是浏览器发给服务器,声明浏 ...

  5. BZOJ2631: tree(LCT)

    Description 一棵n个点的树,每个点的初始权值为1.对于这棵树有q个操作,每个操作为以下四种操作之一: + u v c:将u到v的路径上的点的权值都加上自然数c: - u1 v1 u2 v2 ...

  6. iOS中 学会如何对sqlite3 进行封装

    #waring ---(看官注意) ---使用说明: ①在创建自定义model类之前让该类继承自文件中的Model类, ②为model类选一个NSString属性作为主键:(既,在初始化方法里面将从父 ...

  7. 报错 关于python的x和y不等长

    ValueError: shape mismatch: objects cannot be broadcast to a single shape 这个错误可能是因为传入的两个参数数据长度不一样,比如 ...

  8. Java中接口继承泛型接口

    在使用Mybatis做web开发时,每一个模块的数据持久层的接口都会定义:增删改查四个方法.我想为什么不新建一个Base接口来做所有数据持久层的父接口呢? 于是,我试验了一下,建立了一个泛型接口,里面 ...

  9. 机器学习算法中怎样选取超參数:学习速率、正则项系数、minibatch size

    本文是<Neural networks and deep learning>概览 中第三章的一部分,讲机器学习算法中,怎样选取初始的超參数的值.(本文会不断补充) 学习速率(learnin ...

  10. Android SlideAndDragListView,一个可排序可滑动item的ListView

    SlideAndDragListView简介 SlideAndDragListView,可排序.可滑动item显示”菜单”的ListView. SlideAndDragListView(SDLV)继承 ...