如何在Angular2路由中传递服务功能

时间:2018-07-04 06:02:55

标签: angular angular5 angular2-routing angular2-services angular4-router

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

app-routing.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 { }

1 个答案:

答案 0 :(得分:0)

由于它不在课堂上。您可以在上面调用新的运算符。请参见下面的代码。

希望有帮助。

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