[Angular2 Router] Setup page title with Router events
with Router Page setup Events title Angular2
2023-09-14 08:59:19 时间
import 'rxjs/add/operator/filter'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/mergeMap'; import { Component, OnInit } from '@angular/core'; import { Router, NavigationEnd, ActivatedRoute } from '@angular/router'; import { Title } from '@angular/platform-browser'; @Component({...}) export class AppComponent implements OnInit { constructor( private router: Router, private activatedRoute: ActivatedRoute, private titleService: Title ) {} ngOnInit() { this.router.events .filter(event => event instanceof NavigationEnd) .map(() => this.activatedRoute) .map(route => { while (route.firstChild) route = route.firstChild; return route; }) .filter(route => route.outlet === 'primary') .mergeMap(route => route.data) .subscribe((event) => this.titleService.setTitle(event['title'])); } }
相关文章
- 【论文阅读】Next Point-of-Interest Recommendation with Inferring Multi-step Future Preferences
- ORA-00471: DBWR process terminated with error ORACLE 报错 故障修复 远程处理
- ORA-01784: RECOVERABLE cannot be specified with database media recovery disabled ORACLE 报错 故障修复 远程处理
- ORA-23392: could not find materialized view to be associated with “string”.”string” ORACLE 报错 故障修复 远程处理
- ORA-29475: useLogonRoles=>TRUE not permitted with userid=>NULL ORACLE 报错 故障修复 远程处理
- ORA-55338: a model with the name string already exists ORACLE 报错 故障修复 远程处理
- ORA-01675: max_commit_propagation_delay inconsistent with other instances ORACLE 报错 故障修复 远程处理
- MySQL Error number: MY-011326; Symbol: ER_XPLUGIN_USER_ACCOUNT_WITH_ALL_PERMISSIONS; SQLSTATE: HY000 报错 故障修复 远程处理
- ORA-12091: cannot online redefine table “string”.”string” with materialized views ORACLE 报错 故障修复 远程处理
- ORA-13274: operator invoked with non-compatible SRIDs ORACLE 报错 故障修复 远程处理
- Linux Xev: Exploring Event Detection and ResponseUnlock the Secrets of Event Detection and Response with Linux Xev(linuxxev)
- Exploring the Power of Linux with Jstack: A Comprehensive Guide(linuxjstack)
- Using Java to Work with MongoDB: A Guide for Developers(java操作mongodb)
- Get Started with Lightweight Computing on Light Linux Today!(lightlinux)
- 怎么办? How to Deal with a Stuck MySQL Database?(mysql数据库卡)
- Oracle中利用WITH子句的使用(oracle中的with)