@yafit1 wrote:
I'm using angular 2, and I need to update 'selectedData' property of the component when a node in selected.
Unfortunately, I'm getting an exception:
"Cannot set property 'selectedData' of undefined"this is the relevant code:
export class FlowComponent implements AfterViewInit { selectedData: any; AfterViewInit () { const diagram = $(go.diagram, this.element.nativeElement, { ... } ); diagram.model = $(go.GraphLinksModel, { ... } ); diagram.nodeTemplate = $(go.Node, "Spot", { selectionChanged: this.onSelectionChanged }, ... ); } onSelectionChanged(node: go.Node) { if (node.isSelected) { this.selectedData = node.data; } } ... }
I tried to change it to "this.onSelectionChanged.bind(this)" or to anonymous function, both failed.
Why am I getting this error?
what can I do?
Thanks.
Posts: 5
Participants: 2