1 import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core'
2 import { NavigationEnd, Router } from '@angular/router'
3 import { TabsetComponent } from 'ngx-bootstrap/tabs'
6 templateUrl: './follows.component.html',
7 styleUrls: [ './follows.component.scss' ]
9 export class FollowsComponent implements OnInit, AfterViewInit {
10 @ViewChild('followsMenuTabs') followsMenuTabs: TabsetComponent
14 path: 'following-list',
18 path: 'following-add',
22 path: 'followers-list',
27 constructor (private router: Router) {}
30 this.router.events.subscribe(
32 if (event instanceof NavigationEnd) {
33 this.updateActiveTab()
40 // Avoid issue with change detector
41 setTimeout(() => this.updateActiveTab())
44 private updateActiveTab () {
45 const url = window.location.pathname
47 for (let i = 0; i < this.links.length; i++) {
48 const path = this.links[i].path
50 if (url.endsWith(path) === true && this.followsMenuTabs.tabs[i]) {
51 this.followsMenuTabs.tabs[i].active = true