1 import {Component} from '@angular/core';
2 import {Router, ActivatedRoute, NavigationEnd} from '@angular/router';
3 import {take} from 'rxjs/operators';
4 import {VandelayService} from './vandelay.service';
7 templateUrl: 'vandelay.component.html'
9 export class VandelayComponent {
13 private router: Router,
14 private route: ActivatedRoute,
15 private vandelay: VandelayService) {
17 // As the parent component of the vandelay route tree, our
18 // activated route never changes. Instead, listen for global
19 // route events, then ask for the first segement of the first
20 // child, which will be the tab name.
21 this.router.events.subscribe(routeEvent => {
22 if (routeEvent instanceof NavigationEnd) {
23 this.route.firstChild.url.pipe(take(1))
24 // eslint-disable-next-line rxjs/no-nested-subscribe
25 .subscribe(segments => this.tab = segments[0].path);