[Angular] Auxiliary named router outlets
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的更多相关文章
- Angular.js之Router学习笔记
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...
- http://angular.github.io/router/
Angular New Router Guide Configuring the Router- This guide shows the many ways to map URLs to compo ...
- angular 的ui.router 定义不同的state 对应相同的url
Angular UI Router: Different states with same URL? The landing page of my app has two states: home-p ...
- [Angular 2] Child Router
Benefit to use child router is Angualr 2 then can lazy load the component on demand. Define a child ...
- [Angular] Subscribing to router events
In our root component, one thing we can do is subscribe to Router events, and do something related t ...
- [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 ...
- [Angular2 Router] Build Angular 2 Navigation with routerLink
Angular 2 navigation is configured using the routerLink directive. The routerLink directive behaves ...
- User Authentication with Angular and ASP.NET Core
User authentication is a fundamental part of any meaningful application. Unfortunately, implementing ...
- angular 之路由
1.用angular-cli建一个工程自带路由怎么做? 命令:ng new 项目名 --routing 2.怎么使用路由器和路由器的一些基本使用. //html页面 <a routerLink ...
随机推荐
- 37.Intellij IDEA解决GBK乱码
转自:https://blog.csdn.net/myspacedemen/article/details/38401047 今天尝鲜装完Intellij IDEA以后,打开一个GBK编码的页面,华丽 ...
- 体验SUSE (附视频演示)
操作动画演示 本文出自 "李晨光原创技术博客" 博客,谢绝转载!
- BZOJ2402: 陶陶的难题II(树链剖分,0/1分数规划,斜率优化Dp)
Description Input 第一行包含一个正整数N,表示树中结点的个数.第二行包含N个正实数,第i个数表示xi (1<=xi<=10^5).第三行包含N个正实数,第i个数表示yi ...
- Python 极简教程(一)前言
现在 Python 用处很多,学的人也很多,其流行程度自不必说.但是很多人学 Python 的时候都遇到过问题,特别对于非计算机专业毕业的人来说. 现在的教程非常多,但是绝大部分对于初学者都不够友好. ...
- Spring学习总结(8)——25个经典的Spring面试问答
1.什么是Spring框架?Spring框架有哪些主要模块? Spring框架是一个为Java应用程序的开发提供了综合.广泛的基础性支持的Java平台.Spring帮助开发者解决了开发中基础性的问题, ...
- HDU 2068 RPG的错排(错排公式 + 具体解释)
RPG的错排 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Sub ...
- matlab 辅助函数 —— 文件下载与文件解压
0. 可读性的提升 为了提升代码的交互友好性,可在代码执行一些耗时操作时,显示地输出一些文本信息,以显示进度: fprintf('Downloading xxfilename...\n') urlwr ...
- 非极大值抑制(non-maximum suppression)的理解与实现
非极大抑制(Non-Maximum Suppression) Non-Maximum Suppression for Object Detection in Python RCNN 和微软提出的 SP ...
- kafka同步生产者和异步生产者深入剖析
什么是kafka同步生产者,什么是kafka异步生产者? 比如这里某个topic有3个分区. kafka同步生产者:这个生产者写一条消息的时候,它就立马发送到某个分区去. kafka异步生产者:这个 ...
- Impala基础认知与安装
一.Impala简介 Cloudera Impala对你存储在Apache Hadoop在HDFS,HBase的数据提供直接查询互动的SQL.除了像Hive使用相同的统一存储平台,Impala也使用相 ...