4

I have a problem with my plunkr. http://plnkr.co/edit/70ZFRPJdAraDDV8heMlo?p=preview

const routes = [
    {path: 'test', component: Test},
    {path: 'home', component: HomeComponent},
    {path: '', redirectTo: 'home', pathMatch: "full"}
];

this.router.navigate('/test');

I can't simply do a router.navigate. I have the error :

Error: Cannot match any routes. URL Segment: 't/e/s/t'

Everything looks ok to me. Related to Cannot match any routes: '' but I don't have any children routes.

Thanks

Community
  • 1
  • 1
Meakyl
  • 43
  • 4

2 Answers2

2

Add []

this.router.navigate(['/test']);

or use navigateByUrl()

this.router.navigateByUrl('/test');

Plunker example

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
0

no slash before the path and brackets ...

this.router.navigate(['test']);
danday74
  • 52,471
  • 49
  • 232
  • 283