I finally ended as follow :
since this keyword can not be accessible to access component class methods from the event handler, I had to keep a reference to it . const reference = this; xstart : number; function dragstarted(d) { .. reference.xstart = d3.event.x; } .... d3... .on("start",dragstarted) Le vendredi 1 février 2019 16:29:49 UTC+1, Stéphane Ancelot a écrit : > > Hi, > I have got to implement drag and drop in a svg d3js component. > > the svg elements are created dynamically . > > I want to retrieve the transform attribute of the dragged element in the > drag handler. > > This would mean, I would need ElementRef of these dynamically allocated > element. > > I suppose , the solution needs ViewChildren , but I don't know how to > implement it. > > The elements are created using the following code : > this.g = this.svg.selectAll(".dimension") > .data(dimensions) > .enter().append("g") > .attr("class", "dimension") > > .attr("transform", function(d) { return "translate(0," + _this.y(d > .id) + ")"; }) > > Regards > -- You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group. To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscr...@googlegroups.com. To post to this group, send email to angular@googlegroups.com. Visit this group at https://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.