For example, we have a component which just simply render router-outlet:

import { Component } from '@angular/core';

@Component({
selector: 'mail-app',
styleUrls: ['mail-app.component.scss'],
template: `
<div class="mail">
<router-outlet></router-outlet>
</div>
`
})
export class MailAppComponent {}
export const ROUTES: Routes = [
{ path: 'folder/:name', component: MailFolderComponent }
];

We can add events to router-outlet:

import { Component } from '@angular/core';

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

When we log out the, we see the actual component been rendered into the router-outlet.

[Angular] Router outlet events的更多相关文章

  1. 使用Angular Router导航基础

    名称 简介 Routes 路由配置,保存着那个URL对应着哪个组件,以及在哪个RouterOulet中展示组件. RouterOutlet 在HTML中标记路由内容呈现位置的占位符指令. Router ...

  2. [从 0 开始的 Angular 生活]No.38 实现一个 Angular Router 切换组件页面(一)

    前言 今天是进入公司的第三天,为了能尽快投入项目与成为团队可用的战力,我正在努力啃官方文档学习 Angular 的知识,所以这一篇文章主要是记录我如何阅读官方文档后,实现这个非常基本的.带导航的网页应 ...

  3. [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. ...

  4. MVC route 和 Angular router 单页面的一些方式

    直接看代码和注释吧 ASP.NET MVC router public class RouteConfig { public static void RegisterRoutes(RouteColle ...

  5. [Angular 2] Using events and refs

    This lesson shows you how set listen for click events using the (click) syntax. It also covers getti ...

  6. [Angular] Progress HTTP Events with 'HttpRequest'

    New use case that is supported by the HTTP client is Progress events. To receive these events, we cr ...

  7. angular router ui bug !

    https://github.com/angular-ui/ui-router/issues/600 https://github.com/angular-ui/ui-router/issues/22 ...

  8. [Angular] Adding keyboard events to our control value accessor component

    One of the most important thing when building custom form component is adding accessbility support. ...

  9. [Angular2 Router] Setup page title with Router events

    Article import 'rxjs/add/operator/filter'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator ...

随机推荐

  1. 后台vb校验是否GUID

    '校验是否GUID Private Function IsGUID(ByVal strGUID As String) As Boolean Dim regexTemp As System.Text.R ...

  2. 3. CONFIGURATION官网剖析(博主推荐)

    不多说,直接上干货! 一切来源于官网 http://kafka.apache.org/documentation/ 3. CONFIGURATION 3.1 Broker Configs 3.2 Pr ...

  3. 1.22 Python基础知识 - 正则表达式

    Python正则表达式 正则表达式是一个特殊的字符序列,它能帮助你方便的检查一个字符串是否与某种模式匹配. Python 自1.5版本起增加了re 模块,它提供 Perl 风格的正则表达式模式. re ...

  4. 【Todo】Zookeeper系列文章

    http://nileader.blog.51cto.com/1381108/1068033

  5. DriverModule_01

    最小驱动模块: 最简单的Makefile 无配置文件 最小驱动的四部分 头文件 声明模块信息 模块驱动的入口.出口 功能区 关于这个头文件的分析: linux头文件的位置,例如#include< ...

  6. 学习笔记:_lodash.js常用函数

    _lodash.js 文档:https://www.lodashjs.com/docs/4.17.5.html _.compact(array) 创建一个移除了所有假值的数组 什么是假值?false, ...

  7. [ACM] POJ 1046 Color Me Less

    Color Me Less Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 30146   Accepted: 14634 D ...

  8. 深入并发AQS二

    AQS须要解决下面几个问题: 1.锁状态,怎样保证并发情况下可以安全的更新? 2.当前线程不能获取锁时,放在哪里? AQS是放在一个队列其中 3.怎样提高效率? AQS的主要职责是当获取不到锁时.将线 ...

  9. 【习题 3-10 UVA - 1587】Box

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 枚举某个顶角的三个相邻面就好. 看看这三个相邻面有没有对应的面. 以及3个相邻面的6个边. 能否分成2个a,2个b,2个c 也即每个 ...

  10. [算法系列之二十七]Kruskal最小生成树算法

    简单介绍 求最小生成树一共同拥有两种算法,一个是就是本文所说的Kruskal算法,还有一个就是Prime算法. 在具体解说Kruskal最小生成树算法之前,让我们先回想一下什么是最小生成树. 我们有一 ...