2016-11-07 77 views
3

我的plunkr有问题。 http://plnkr.co/edit/70ZFRPJdAraDDV8heMlo?p=preview角度不匹配任何路线2.0.1

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

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

我不能简单地做一个router.navigate。我有错误:

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

一切看起来都对我好。 与Cannot match any routes: ''相关,但我没有任何儿童路线。

感谢

回答

2

添加[]

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

或使用

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

Plunker example

+0

非常感谢就是这样。 – Meakyl

0

路径和括号前没有斜杠...

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