In an Angular directive, I am trying to access a class-level variable inside a callback function. To achieve this, I used an arrow function but the 'this' keyword is still not pointing to the directive.
this.itemRects.selectAll('rect')
.data(this.visItems, (d) => {
return d.id + this.x;
})
I added a debugger at the return statement, and upon inspection it shows that 'this' is referring to the data array rather than the directive itself.
Is there a way to correctly access the directive level 'this' inside the callback function?