动态更改' redirectTo'基于服务

时间:2017-12-02 12:00:25

标签: angular angular-services angular-router angular-module

这就是我的模块的外观

const routes: Routes = [
  {
    path: 'home', component: HomeComponent,
    children: [
      { path: '', redirectTo: 'compact', pathMatch: 'full' },
      { path: 'compact', component: CompactComponent },
      { path: 'reports', component: ResearchReportsComponent },
    ]
  }
];

@NgModule({
  imports: [
    CommonModule
    RouterModule.forChild(routes)
  ],
  declarations: [
    HomeComponent
  ]
})
export class HomeModule {
}

我想让redirectTo值取决于来自myservice的变量。

0 个答案:

没有答案