aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/app/app.component.ts
diff options
context:
space:
mode:
authorNevena Bojovic <nenabojov@gmail.com>2022-03-19 22:38:34 +0100
committerNevena Bojovic <nenabojov@gmail.com>2022-03-19 22:38:34 +0100
commit5f40d4a21a09b481343f894eab7970de895744d7 (patch)
tree3fcfaca394e9a9586bf944c389ffc4e907ec2664 /frontend/src/app/app.component.ts
parent347ce115be33fce7ce3bd7a91e240f8f4e3fb901 (diff)
parentff5bf81a14d3024f8ff1764db488dec6790ed37e (diff)
Merge branch 'dev' of http://gitlab.pmf.kg.ac.rs/igrannonica/neuronstellar into dev
Diffstat (limited to 'frontend/src/app/app.component.ts')
-rw-r--r--frontend/src/app/app.component.ts33
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`);
+ }
+ });
+ }
}