fix: Sidans titel ändras nu korrekt när man går tillbaka till startsidan. (TV-643)

Squashed commit of the following:

commit b70383f449eb2e17e0da2e479316c821cdf4bb85
Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se>
Date:   Wed Sep 22 15:04:38 2021 +0200

    fix: Flyttade titlesättning från layout.component till app.component. Krävde mer logik för att hitta vilken route man är på. (TV-643)
This commit is contained in:
Daniel Appelgren
2021-09-23 11:01:12 +02:00
parent 454699b785
commit 0302b1a1ad
2 changed files with 28 additions and 6 deletions

View File

@@ -40,17 +40,13 @@ export class LayoutComponent extends UnsubscribeDirective {
private router: Router,
private activatedRoute: ActivatedRoute,
private authenticationService: AuthenticationService,
private userService: UserService,
private titleService: Title
private userService: UserService
) {
super();
super.unsubscribeOnDestroy(
this.router.events.pipe(filter(event => event instanceof NavigationEnd)).subscribe(() => {
const pageTitle = this.activatedRoute?.snapshot?.data?.title as string;
const urlTree = this.router.parseUrl(this.router.url);
this.titleService.setTitle(`${pageTitle ? `${pageTitle} - ` : ''}Mina sidor för fristående aktörer`);
if (urlTree.queryParams.code) {
void this.router.navigate([], {
relativeTo: this.activatedRoute,