首页 > 代码库 > [Angular] Router outlet events
[Angular] Router outlet events
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。