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. java创建节点和单向链表

    package datastructure; public class Node { private Object data; private Node next; public Node() { t ...

  2. Error: org.apache.mahout.math.CardinalityException: Required cardinality 10 but got 30问题解决办法

    问题详情 在运行mahout中kmeans算法时,采取的是其默认输入路径/user/hadoop/testdata 和 默认输出路径/user/hadoop/output. [hadoop@djt00 ...

  3. vue2.0实现银行卡类型种类的选择

    功能效果:vue2.0实现银行卡类型种类的选择 图片.png 参考代码如下: <template> <div class="app"> <header ...

  4. ubuntu下useradd与adduser差别,新建用户不再home文件夹下

    useradd username不会在/home下建立一个目录username adduser username会在/home下建立一个目录username useradd -m username跟a ...

  5. JAVE 视音频转码

    http://blog.csdn.net/qllinhongyu/article/details/29817297

  6. android问题及其解决-优化listView卡顿和怎样禁用ListView的fling

    问题解决-优化listView卡顿和怎样禁用ListView的fling 前戏非常长,转载请保留出处:http://blog.csdn.net/u012123160/article/details/4 ...

  7. Android圆环控件

    Android圆环控件 近期在做一个功能.界面效果要求例如以下: 看到这个界面,我首先想到了曾经在做phone模块的时候,我们定制的来电界面InCallTouchUi,界面效果是相似的. 来电控件使用 ...

  8. 并发,one

    引言 最近工作当中写了一个有关并发的程序,引起了LZ对并发的强烈兴趣.这一下一发不可收拾,LZ用了一个多星期,看完了这本共280+页的并发编程书.之所以能看这么快,其实这主要归功于,自己之前对并发就有 ...

  9. Altium Designer导入pcb原件之后都是绿的

  10. Spring拦截器和Servlet过滤器区别

    http://blog.csdn.net/chenleixing/article/details/44573495