面包屑用'重定向到'使用Angular的组件

时间:2018-06-19 10:43:07

标签: javascript angular typescript web breadcrumbs

我正在Angular项目中工作,我需要添加面包屑,但我遇到了问题......

我的组件使用嵌套' redirectTo',例如:



//app-routing.module.ts
//Here: Home
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
@NgModule({
  imports: [
    RouterModule.forRoot([
      {
        path: "",
        pathMatch: "full",
        redirectTo: "/pass/login"
      },
      {
        path: "pass",
        pathMatch: "full",
        redirectTo: "/pass/login"
      }
    ])
  ],

  exports: [RouterModule]
})
export class AppRoutingModule {}






//home-routing.module.ts
//Here: Home > Credit Simulation
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import {HomeComponent} from './home/home.component';

@NgModule({
  imports: [
    RouterModule.forChild([
      {
        component: HomeComponent,
        path: 'pass/home',
        data: {
          breadcrumb: 'Credit Simulation' //I tried
        }
      }
    ])
  ],

  exports: [RouterModule]
})
export class HomeRoutingModule {
}






//request-routing.module.ts
//Here: Home > Credit Simulation > Preq
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import {PreqComponent} from './preq/preq.component';
import {RequestComponent} from './request/request.component';


@NgModule({
  imports: [
    RouterModule.forChild([
      {
        component: PreqComponent,
        path: 'pass/preq'
      },
      {
        component: RequestComponent,
        path: 'pass/request'
      }
    ])
  ],

  exports: [RouterModule]
})
export class RequestRoutingModule {
}




我在社区中尝试了很多解决方案,并在app.routing.ts

中使用了儿童和路线

我有一个线索:可能是通过组件的对象,但是如何?

请建议我解决这个问题。

0 个答案:

没有答案