import { Component, OnInit } from '@angular/core'; import { Router, NavigationEnd } from '@angular/router'; import { Navigate } from './../../config/navigate'; @Component({ selector: 'app-navigate', templateUrl: './navigate.component.html', styleUrls: ['./navigate.component.less'] }) export class NavigateComponent implements OnInit { navs = Navigate; path = location.pathname; constructor(private router:Router) { } ngOnInit() { this.router.events .subscribe((event) => { if (event instanceof NavigationEnd) { this.path = location.pathname; } }); } }