Hi, I have a question about how I can update a variable of my Angular component within a click method of the ContextMenu. In the click method I make a diagram.commit and in it I update information of my groups, but I also need to update a variable of the component, and when using this.varible it doesn’t update it or returns undefined, so I can’t update that value in my template. I was checking and implementing a GraphObject.click, but it didn’t work either. Is there any way to get the value change or return the variable out of the diagram context?
Are you referring to
this inside a
function? If so, use an arrow function instead.
Yes, I’m using an arrow function. And inside it I do the diagram.commit to update the groups and that’s where I need to update the component’s variable using “this.variable”
Is the problem that
this is not referring to what you want? I’m not sure I can help with this.
The function where I make those changes is defined inside the initDiagram( ), and inside it my variable is updated when I make “this.variable”, but if I want to use it outside that context, it is not updated…
I don’t know what to say. If you don’t have a reference to the object that has the property you want, you’ll need to get it.
I solved it already. I did it using an addDiagramListener ( LayoutCompleted ), in ngAfterViewInit. I checked the changes of the diagram and based on that I updated my component variable. Thanks.