【发布时间】:2019-07-18 07:15:03
【问题描述】:
我有一个角度组件,其中我有一个函数与另一个函数。
当我点击一个在我的函数中绘制的按钮时,我只想更改页面。我无法访问在组件的构造函数中声明的路由器。那么有人知道怎么做吗?
这是我的组件的代码:
export class EncoursComponent{
constructor(private serviceData : DataService, private router : Router) {
}
}
//Fonction qui permet de dessiner les lignes et les points
draw(id: any, events: any, options: any) {
//Ici on définit les points
svg.selectAll("circle")
//I want that when I click, be redirected no another page
.on("click", function(d: any) {
var data : DataService = new DataService();
//This line doesn't work
var rout : Router = new Router();
//I can't acces to this.router
this.router.navigate("/affecter");
});
}
【问题讨论】:
标签: angular typescript routing