1 import {Component, OnInit, AfterViewInit, ViewChild} from '@angular/core';
2 import {Router, ActivatedRoute, NavigationEnd} from '@angular/router';
3 import {take} from 'rxjs/operators';
4 import {VandelayService} from './vandelay.service';
5 import {IdlObject} from '@eg/core/idl.service';
8 templateUrl: 'vandelay.component.html'
10 export class VandelayComponent implements OnInit, AfterViewInit {
14 private router: Router,
15 private route: ActivatedRoute,
16 private vandelay: VandelayService) {
18 // As the parent component of the vandelay route tree, our
19 // activated route never changes. Instead, listen for global
20 // route events, then ask for the first segement of the first
21 // child, which will be the tab name.
22 this.router.events.subscribe(routeEvent => {
23 if (routeEvent instanceof NavigationEnd) {
24 this.route.firstChild.url.pipe(take(1))
25 .subscribe(segments => this.tab = segments[0].path);