diff options
author | Danijel Andjelkovic <adanijel99@gmail.com> | 2022-03-16 18:16:56 +0100 |
---|---|---|
committer | Danijel Andjelkovic <adanijel99@gmail.com> | 2022-03-16 18:16:56 +0100 |
commit | d96b69f4ca8eac83140b3b451f59621aed2bb517 (patch) | |
tree | 5aa188e8799781616d5465762fe92f50ae376178 /frontend/src/app/app.component.ts | |
parent | f6496f86182902f2a6e5e34554ae93116d04c5b6 (diff) |
Dodao naslove za sve strane, i zapoceo my-datasets.
Diffstat (limited to 'frontend/src/app/app.component.ts')
-rw-r--r-- | frontend/src/app/app.component.ts | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/frontend/src/app/app.component.ts b/frontend/src/app/app.component.ts index 9d6b2f11..f5ae5786 100644 --- a/frontend/src/app/app.component.ts +++ b/frontend/src/app/app.component.ts @@ -1,10 +1,37 @@ -import { Component } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; +import { Title } from '@angular/platform-browser'; +import { Router, NavigationEnd, ActivatedRoute } from '@angular/router'; +import { filter, map } from 'rxjs'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) -export class AppComponent { - title = 'frontend'; +export class AppComponent implements OnInit { + + constructor(private router: Router, private titleService: Title) { } + + ngOnInit() { + this.router.events + .pipe( + filter((event) => event instanceof NavigationEnd), + map(() => { + let route: ActivatedRoute = this.router.routerState.root; + let routeTitle = ''; + while (route!.firstChild) { + route = route.firstChild; + } + if (route.snapshot.data['title']) { + routeTitle = route!.snapshot.data['title']; + } + return routeTitle; + }) + ) + .subscribe((title: string) => { + if (title) { + this.titleService.setTitle(`${title} - Igrannonica`); + } + }); + } } |