Angular 2+ 监听路由变化动态设置页面标题
生活随笔
收集整理的這篇文章主要介紹了
Angular 2+ 监听路由变化动态设置页面标题
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
原網址:https://segmentfault.com/a/1190000009971757
路由配置代碼:const routes: Routes = [{ path: 'calendar', component: CalendarComponent, children: [ { path: '', redirectTo: 'new', pathMatch: 'full' }, { path: 'all', component: CalendarListComponent, data: { title: 'My Calendar' } }, { path: 'new', component: CalendarEventComponent, data: { title: 'New Calendar Entry' } }, { path: ':id', component: CalendarEventComponent, data: { title: 'Calendar Entry' } } ] }];
根組件設置代碼: 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';
?
轉載于:https://www.cnblogs.com/lyls/p/7471773.html
總結
以上是生活随笔為你收集整理的Angular 2+ 监听路由变化动态设置页面标题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 消防用无缝钢管和镀锌管的材质区别?
- 下一篇: Session机制二(简易购物车案例)