Define a auxilliary router:

export const ROUTES: Routes = [
{
path: 'folder/:name',
component: MailFolderComponent,
resolve: {
messages: MailFolderResolver
}
},
{
path: 'message/:id',
component: MailViewComponent,
outlet: 'pane',
resolve: {
message: MailViewResvoler
}
}
];

HTML:

@Component({
selector: 'mail-app',
styleUrls: ['mail-app.component.scss'],
template: `
<div class="mail">
<router-outlet
(activate)="onActivate($event)"
(deactivate)="onDeactivate($event)"
></router-outlet>
</div>
<div class="mail">
<router-outlet
name="pane"
></router-outlet>
</div>
`
})

Routing by routerLink:

    <a
class="mail-item"
[routerLink]="['', {outlets: {pane: ['message', message.id]}}]"
routerLinkActive="active">

Clean auxiliary router:

          <a
[routerLink]="[ { outlets: { primary: 'folder/inbox', pane: null } } ]"
routerLinkActive="active">
Inbox
</a>
<a
[routerLink]="[ { outlets: { primary: 'folder/trash', pane: null } } ]"
routerLinkActive="active">
Trash
</a>

Routing by JS:

  openMessage(e) {
e.preventDefault();
this.router.navigate(['', {outlets: {pane: ['message', this.message.id]}}])
}

RouterLink's advantage:

Angular will convert routerLink to an 'a' tag, so all the broswer feature for 'a' tag you can get from RouterLink.

[Angular] Auxiliary named router outlets的更多相关文章

  1. Angular.js之Router学习笔记

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  2. http://angular.github.io/router/

    Angular New Router Guide Configuring the Router- This guide shows the many ways to map URLs to compo ...

  3. angular 的ui.router 定义不同的state 对应相同的url

    Angular UI Router: Different states with same URL? The landing page of my app has two states: home-p ...

  4. [Angular 2] Child Router

    Benefit to use child router is Angualr 2 then can lazy load the component on demand. Define a child ...

  5. [Angular] Subscribing to router events

    In our root component, one thing we can do is subscribe to Router events, and do something related t ...

  6. [Angular2 Router] Auxiliary Routes bit by bit

    Article Github Auxiliary Routes is is little bit hard to understand. Here is demo, link You can see ...

  7. [Angular2 Router] Build Angular 2 Navigation with routerLink

    Angular 2 navigation is configured using the routerLink directive. The routerLink directive behaves ...

  8. User Authentication with Angular and ASP.NET Core

    User authentication is a fundamental part of any meaningful application. Unfortunately, implementing ...

  9. angular 之路由

    1.用angular-cli建一个工程自带路由怎么做? 命令:ng new  项目名 --routing 2.怎么使用路由器和路由器的一些基本使用. //html页面 <a routerLink ...

随机推荐

  1. Cookie应用--显示看过的商品

    package cn.itcast; import java.io.IOException; import java.io.PrintWriter; import java.util.LinkedHa ...

  2. make 2>&1 | tee build.log

    make 2>&1 | tee build.log 保存编译log,方便问题查找

  3. 给VG增加磁盘,给文件目录增加空间

    一: #lspv 找到新增加的物理卷(逻辑驱动器,以hdisk8为例). #chdev –l hdisk8 –a pv=yes写入新的物理卷的pvid. #extendvg cwdatavg hdis ...

  4. 多线程中的&quot;断点&quot;续传《notify()和wait()》

    眼下在做一个项目.关于软件管理与下载的,预计项目提交日期定在6月9号.项目做了有20天了,可是在一个功能上卡住了.在这个项目中有一个功能----APK的下载须要实现. 相信大家都玩过非常多关于下载AP ...

  5. 20.SpringBoot 之 读取环境变量和绑定属性对象

    转自:https://blog.csdn.net/catoop/article/details/50548009

  6. Log4j中为什么设计isDebugEnabled()方法

    转自:https://www.jianshu.com/p/e1eb7ebfb21e 先看下面的代码,在真正执行logger.debug()之前,进行了logger.isDebugEnabled()的判 ...

  7. java线程——详解Callable、Future和FutureTask

    回顾: 接上篇博客 java线程--三种创建线程的方式,这篇博客主要介绍第三种方式Callable和Future.比较继承Thread类和实现Runnable接口,接口更加灵活,使用更广泛.但这两种方 ...

  8. 算法中的优化问题(optimization problem)

    和多数算法不同的是,有些问题的答案不只一个,而是需要在多个答案中,按照一定标准选出"最佳"答案,这类问题就统称为"优化问题"(optimization prob ...

  9. winform中comboBox控件加默认选项的问题

    winform程序设计中,label,TextBox,ComboBox等几个控件几乎是用得最多的,在设计中经常会遇到一些小问题,如:comboBox控件绑定了数据源之后,如何设置默认值? combob ...

  10. HttpWatch--time chart分析

    这是一个IE的插件,下载可以点这里.下载后解压如下图所示,一共有4个文件.HttpWatch Professional是单独软件,可以单独使用. 解压后有四个文件 插件安装时,只需运行httpwatc ...