I'm working with vis.js network in my Angular project.
I have this code to get the selected node, this code is in my ngOnInit():
network.on('click', function (properties) {
var nodeID = properties.nodes[0];
var edgeFrom = properties.edges
if (nodeID) {
console.log("Selected node id:",nodeID)
this.selectedNode = nodeID //Error here
}
});
But I get an error (see code above) "'this' implicitly has type 'any' because it does not have a type annotation".
Can anyone explain how I should approach filling a global variable with this ID?