Can the dynamic title tag be preserved when the page is refreshed?
When I refresh the page, the title tag reverts back to the original one specified in the index.html
temporarily before switching back to the dynamically added one. I want the title tag to remain consistent even during page refresh.
Below is code snippet from my app.component.ts file:
this.router.events.pipe(
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) => {
console.log(event)
this.translateService.get(event['title']).subscribe(name => {
this._seoService.updateTitle(name);
});
this._seoService.updateDescription(event['description'])
});