Почему функция навигации моего роутера не работает в angular 8? - PullRequest
0 голосов
/ 23 апреля 2020

Я пытаюсь перенаправить на другой компонент, например так:

HomeComponent

  checkUrl(reference) {   
    if (reference != this.ref) {
      this.router.navigate(['/еrror']);
    }
  }

вот мой модуль маршрутизатора

const routes: Routes = [
  { path: '', component: DefaultComponent },
  {
    path: '',
    children: [
      { path: ':dlr/:id/:ref', component: HomeComponent },
      { path: 'error', component: ErrorPageComponent },
    ]
  },
  { path: '**', redirectTo: '', pathMatch: 'full' }

];

сейчас я нахожусь в HomeComponent и хочу go на страницу с ошибкой.

this.router.navigate (['/ еrror']) это приводит меня к DefaultComponent

1 Ответ

0 голосов
/ 24 апреля 2020
 this.router.navigate(['/error'], { relativeTo: this.activatedRoute });

добавление относительно у меня сработало.

...