Skip to content

Instantly share code, notes, and snippets.

@webcat12345
Last active November 6, 2017 17:47
Show Gist options
  • Save webcat12345/a65047e19fcdc2c9a8d465a41766de86 to your computer and use it in GitHub Desktop.
Save webcat12345/a65047e19fcdc2c9a8d465a41766de86 to your computer and use it in GitHub Desktop.
constructor(
private router: Router,
private activatedRoute: ActivatedRoute,
private titleService: Title
) {}
ngOnInit(): void {
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']);
this.pageInfo = event;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment