如何通过Angular2路线的服务功能

如何通过Angular2路线的服务功能,angular,angular5,angular2-routing,angular2-services,angular4-router,Angular,Angular5,Angular2 Routing,Angular2 Services,Angular4 Router,如何在路径中指定“TTENCommonService.getRole()”? 在getRole()事件中,我返回了字符串值 应用程序路由.module.ts import { TTENCommonService } from './tten-common/services/tten- common.service'; const routes: Routes = [ { path: '', redirectTo: '/dashboard '+ TTENCommonServic

如何在路径中指定“TTENCommonService.getRole()”? 在getRole()事件中,我返回了字符串值

应用程序路由.module.ts

import { TTENCommonService } from './tten-common/services/tten- 
  common.service';

const routes: Routes = [
  {
    path: '', redirectTo: '/dashboard '+ TTENCommonService.getRole(), pathMatch: 'full'
  }
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})

export class AppRoutingModule { }

因为这是课外活动。你可以打电话给新的接线员。请参阅下面的代码

希望能有帮助

const routes: Routes = [
  {
    path: '', redirectTo: '/dashboard '+ new TTENCommonService().getRole(), pathMatch: 'full'
  }
];