Reputation: 43
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
Upvotes: 4
Views: 814
Reputation: 56936
no slash before the path and brackets ...
this.router.navigate(['test']);
Upvotes: 0
Reputation: 657068
Add []
this.router.navigate(['/test']);
or use navigateByUrl()
this.router.navigateByUrl('/test');
Upvotes: 2