Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to get access to private variable inside class function

Tags:

angular

I am working in an angular project and designing d3 pie charts. Everything works fine. But my problem is that I am not able to access class private variable inside a function.

like image 220
Passionate Coder Avatar asked Oct 26 '25 03:10

Passionate Coder


1 Answers

Scope issue. Change

.attr('y', function (d, i) { return (this.legendHeight * (i + 1))})

To

.attr('y', (d, i) => { return (this.legendHeight * (i + 1))})

One of many docs


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!