Проблема с угловыми 4 маршрутами - PullRequest
0 голосов
/ 02 мая 2018

Когда я выполняю этот код для перенаправления на другой компонент

this.router.navigate(['/distributed-chart/' + this.invested.risk]);

У меня есть эта проблема в консоли:

ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL 
Segment: 'distributed-chart/54f9ef8a84d534d9490002d1'

приложение-routing.module.ts

const routes: Routes = [
    { path: '', redirectTo: 'simulation/simulate-saving-plan', pathMatch: 'full' },
    { path: 'simulation', loadChildren: 'app/simulation/simulation.module#SimulationModule' },
];

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

имитационные-routing.module.ts

const routes: Routes = [
  { path: '', component: SimulationComponent,
  children:[
    { path: 'simulate-saving-plan', component: SimulateSavingPlanComponent },
    { path: 'distributed-chart/:risk', component: DistributedChartComponent },
    { path: 'expected-rent-chart', component: ExpectedRentChartComponent },
    { path: 'historic-chart', component: HistoricChartComponent }
  ]}
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule],
})
export class SimulationRoutingModule { }

1 Ответ

0 голосов
/ 03 мая 2018

(Опубликован ответ от имени автора вопроса) .

Проблема была здесь:

this.router.navigate(['/simulation/distributed-chart/' + this.invested.risk]);

Я должен добавить "симуляцию" при запуске навигации роутера, решено!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...