[Angular Router] Lazy loading Module with Auxiliary router
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>
[Angular Router] Lazy loading Module with Auxiliary router的更多相关文章
- [Angular 8] Lazy loading with dynamic loading syntax
@NgModule({ declarations: [AppComponent, HomeComponent], imports: [ BrowserModule, MatSidenavModule, ...
- [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 ...
- [AngularJS] Lazy loading Angular modules with ocLazyLoad
With the ocLazyLoad you can load AngularJS modules on demand. This is very handy for runtime loading ...
- [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 ...
- [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 ...
- Angular2+typescript+webpack2(支持aot, tree shaking, lazy loading)
概述 Angular2官方推荐的应该是使用systemjs加载, 但是当我使用到它的tree shaking的时候,发现如果使用systemjs+rollup,只能打包成一个文件,然后lazy loa ...
- Lazyr.js – 延迟加载图片(Lazy Loading)
Lazyr.js 是一个小的.快速的.现代的.相互间无依赖的图片延迟加载库.通过延迟加载图片,让图片出现在(或接近))视窗才加载来提高页面打开速度.这个库通过保持最少选项并最大化速度. 在线演示 ...
- Can you explain Lazy Loading?
Introduction Lazy loading is a concept where we delay the loading of the object until the point wher ...
- iOS swift lazy loading
Why bother lazy loading and purging pages, you ask? Well, in this example, it won't matter too much ...
随机推荐
- Appium定义接口测试
1.Appium如何执行 Appium作为一个服务器,python的脚本代码交给Appium服务器,Appium再去与设备交互. desired_cap = {} desired_cap['platf ...
- JavaScript学习总结(2)——JavaScript数据类型判断
最近做项目中遇到了一些关于javascript数据类型的判断处理,上网找了一下资料,并且亲自验证了各种数据类型的判断,在此做一个总结吧! 一.JS中的数据类型 1.数值型(Number):包括整数. ...
- ArcGIS Engine 线段绘制
转自ArcGIS Engine 线段绘制研究 基本步骤 构建形状 1. 创建 IPoint IPoint m_Point = new PointClass(); m_Point.PutCoords(x ...
- 囧 appspot.com/
囧 appspot.com/ 我负责公司人事,最近车间招了一批外来打工妹,让她们填写个人资料表格,早上在看表格登记,发现其中一张政治面貌一栏赫然写着"瓜子脸",当时笑得眼泪直流,没 ...
- bootstrap课程10 从外部引入视频到页面用什么标签
bootstrap课程10 从外部引入视频到页面用什么标签 一.总结 一句话总结:a.iframe标签:b.embed标签:c.video标签 1.bootstrap具有响应式特性的嵌入内容如何实现? ...
- 2. Dubbo和Zookeeper的关系
转自:https://www.cnblogs.com/hirampeng/p/9540243.html Dubbo建议使用Zookeeper作为服务的注册中心. 1. Zookeeper的作用: ...
- docker网络访问
一 docker网络访问 描述: 在启动容器的时候,如果不指定对应的参数,在容器外部是无法通过网络来访问容器内的网络应用和服务的.当容器中运行一些网络应用,要让外部访问这些应用时,可以通过-P或者-p ...
- js常用数据转换&判断
数组转字符串 var a, b; a = new Array(0,1,2,3,4); b = a.join("-"); //"0-1-2-3-4" 字符串转数组 ...
- 二、MongoDB基础知识
1.文档是MongoDB的核心概念.文档就是键值对的一个有序集{'msg':'hello','foo':3}.类似于python中的有序字典. 需要注意的是: #1.文档中的键/值对是有序的. #2. ...
- 洛谷 P2299 Mzc和体委的争夺战
洛谷 P2299 Mzc和体委的争夺战 题目背景 mzc与djn第四弹. 题目描述 mzc家很有钱(开玩笑),他家有n个男家丁(做过前三弹的都知道).但如此之多的男家丁吸引来了我们的体委(矮胖小伙), ...