import { Component, OnInit } from '@angular/core';
import {filter, map} from 'rxjs/operators';
import {Router, NavigationEnd} from "@angular/router";
@Component({
selector: 'app-content',
templateUrl: './content.component.html',
styleUrls: ['./content.component.css']
})
export class ContentComponent implements OnInit {
pageTitle = '';
pageDesc = '';
constructor(public router: Router) {
//新版本rxjs filter要放在pipe中用
const filterRouter = router.events.pipe(
filter(event => event instanceof NavigationEnd)
);
filterRouter.subscribe((event: NavigationEnd) => {
if (event.url == '/dashboard') {
this.pageTitle = '这里是首页';
this.pageDesc = '首页描述';
} else if (event.url.startsWith('/stock')) {
this.pageTitle = '股票信息管理';
this.pageDesc = '股票信息基本增删改查';
}
})
}
ngOnInit() {
}
}