I have an angular 6 application where i want to store the page title on every route change,
import { Router, NavigationEnd, NavigationStart, RoutesRecognized } from '@angular/router';
export class AppComponent implements OnInit {
constructor (
public router: Router
) {
}
ngOnInit() {
this.router.events.subscribe(event => {
if (event instanceof NavigationStart) {
// console.log('Starting Navigation');
}
if (event instanceof NavigationEnd) {
console.log('Ending Navigation ', document.title);
}
});
}
the issue is whenever i want to access the title of the current page , it shows the previous title set but not the new title which is being set dynamically from the component level
Any suggestion how to fix this ?