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. PHP和JSON

    PHP和JSON 一.总结 1.php中json的使用方法:php中json的使用超级简单啦,主要是两个函数json_encode(编码)和json_decode(解码),像md5加密 2.json的 ...

  2. Android广告轮播图实现

    先看效果 第一步,布局 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmln ...

  3. GPU-Z:显卡体质、显卡各传感器实时状态的查看

    1. TechPowerUp GPU-Z:查看显卡体质 下载地址:Download TechPowerUp GPU-Z | techPowerUp 点击 bus interface 后的?进行显卡的体 ...

  4. 27.mutex跨进程通信

    创建互斥量mutex HANDLE mutex = CreateMutexA(NULL, TRUE, name); 根据id打开mutex HANDLE mutex = OpenMutexA(MUTE ...

  5. JS实践与写博客-序

    大二的时候,就开始接触JavaScript了. 当时学了1年多,主要是认真看了一本JavaScript的入门书籍,了解了JavaScript大致怎么回事.在独自做Web项目的时候,用的都是JavaSc ...

  6. springMVC通过ajax传递参数list对象或传递数组对象到后台

    springMVC通过ajax传递参数list对象或传递数组对象到后台 环境: 前台传递参数到后台 前台使用ajax 后台使用springMVC 传递的参数是N多个对象 JSON对象和JSON字符串 ...

  7. Linux常用运维命令小结

    1. 空设备文件以及标准输入输出 /dev/null 表示空设备文件 0 表示stdin标准输入 1 表示stdout标准输出 2 表示stderr标准错误 2>&1 这里有两种解释:将 ...

  8. 软件——protel 的pcb电路图制作

    近期一直在学习PCB板的绘制.

  9. QSYS系统简介

    QSYS是SoPC Builder的新一代产品. QSYS系统集成工具自动生成互联逻辑,连接IP和子系统 QSYS的设计理念是提高设计抽象级,从而使机器自动生成底层代码. Altera的Avalon总 ...

  10. Surging Demo 项目之一

    原文:Surging Demo 项目之一 开发与运行环境 IDE Visual Stadio 2017/Visual Stadio 2019 Visual Stadio Core Docker 和 D ...