Angular2 TypeError: linkParams.forEach is not a function

Angular2 TypeError: linkParams.forEach is not a function

我正在尝试通过单击事件的函数显式导航到路由

<a (click)="loadContact()">Contact</a>

AppComponent class是这样定义的

export class AppComponent{

    constructor(private _router:Router){}

    public loadContact = function(){
        ...
        ...
        this._router.navigate('[Contact]');
    }
}

但是我收到了这个错误

TypeError: linkParams.forEach is not a function

我该如何解决?

编辑:

这是路由配置

@RouteConfig([
    { path: '/contact', name: 'Contact', component: ContactsComponent },
    { path: '/notes', name: 'Notes', component: NotesComponent }
])

TypeError: linkParams.forEach is not a function

错误原因:When a redirect, or router link is setup incorrectly and an array is not provided, an error is thrown

据报告也提供更好的错误处理:https://github.com/angular/angular/issues/7952

您的代码

此处:

this._router.navigate('[Contact]');

是一个字符串。应该是:

this._router.navigate(['Contact'] /* some array */);

更多

https://angular.io/docs/ts/latest/guide/router.html#!#link-parameters-array

 this._router.navigate(['Contact']);