angular获取当前路由信息

 children: [
      {
        path: '',
        redirectTo: 'houseManage',
        pathMatch: 'full'
      },
      {
        path: 'houseManage',
        data: {
          title: '楼盘管理'
        },
        loadChildren: () =>
          import('./houseManage/houseManage.module').then(
            m => m.HouseManageModule
          )
      },
      {
        path: 'operateManage',
        data: {
          title: '运营方管理'
        },
        loadChildren: './operateManage/operateManage.module#OperateManageModule'
      },

import { ActivatedRoute, Router } from '@angular/router';
想要获取当前路由地址path :
this.router.url
想要获取当前路由的title:
this.activatedRoute.data.subscribe(res => console.log(res));

const data = this.activatedRoute.snapshot.data;

猜你喜欢

转载自blog.csdn.net/Tom__cy/article/details/102895633