【发布时间】:2016-04-08 05:51:21
【问题描述】:
我正在尝试从点击事件中的函数显式导航到路由
<a (click)="loadContact()">Contact</a>
AppComponent 类是这样定义的
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 }
])
【问题讨论】:
-
发布
Contact路由配置? -
你能展示AppComponent的
@Component装饰器和bootstrap()吗? -
如果我使用
<a [routerLink]="['Contact']">Contact</a>,它会起作用,但这不是我想要的。当我从菜单中选择联系选项时,我需要做一些事情 -
不需要更多代码。对
navigate的调用是错误的????
标签: typescript angular angular2-routing