diff options
Diffstat (limited to 'src/app/app.component.ts')
-rw-r--r-- | src/app/app.component.ts | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/app/app.component.ts b/src/app/app.component.ts index cb12491..5ee4946 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts | |||
@@ -23,14 +23,37 @@ | |||
23 | */ | 23 | */ |
24 | 24 | ||
25 | import { Component } from '@angular/core'; | 25 | import { Component } from '@angular/core'; |
26 | import { Router, ActivatedRoute, NavigationEnd } from '@angular/router'; | ||
27 | |||
28 | |||
29 | import { filter } from 'rxjs/operators'; | ||
26 | 30 | ||
27 | @Component({ | 31 | @Component({ |
28 | selector: 'app-root', | 32 | selector: 'app-root', |
29 | templateUrl: './app.component.html', | 33 | templateUrl: './app.component.html' |
30 | //styleUrls: ['./../scss/main.scss'] | ||
31 | }) | 34 | }) |
32 | 35 | ||
33 | 36 | ||
34 | export class AppComponent { | 37 | export class AppComponent { |
35 | title = ''; | 38 | |
39 | private active: number = 0; | ||
40 | |||
41 | menu : any[] = [ | ||
42 | {id:0, name: 'Main', link: ''}, | ||
43 | {id:1, name: 'Identities', link: 'identity'}, | ||
44 | {id:2, name: 'Names', link: 'namestore'}, | ||
45 | {id:3, name: 'Peers', link: 'peerstore'}, | ||
46 | ]; | ||
47 | |||
48 | constructor(private router: Router) { | ||
49 | router.events.pipe(filter(event => event instanceof NavigationEnd)) | ||
50 | .subscribe((route: ActivatedRoute) => { | ||
51 | let index = this.menu.find(x => { | ||
52 | let url = '/'+x.link; | ||
53 | return url == route.url+''; | ||
54 | }); | ||
55 | this.active = this.menu.indexOf(index); | ||
56 | }); | ||
57 | } | ||
58 | |||
36 | } | 59 | } |