Reputation: 1124
I'm not able to bind global variable.
here my code.
mxEvent.addListener(img, 'click',
mxUtils.bind(this, function(evt:any) {
this.enableRightSideBar = true;
console.log(this.enableRightSideBar);
}.bind(this))
)
console.log(this.enableRightSideBar, 'this.enableRightSideBar');
Show me "true", but it's not reflected on html.
Please help me.
Upvotes: 3
Views: 409
Reputation: 657008
There isn't much information in your question but I guess this is what you need to do:
mxEvent.addListener(img, 'click', (event:any) => { this.enableRightSideBar = true; })
Update
Seems this callback is fired outside angular zone so you can use ChangeDetectorRef to refresh view:
constructor(private cdRef: ChangeDetectorRef) {}
...
this.enableRightSideBar = true;
this.cdRef.detectChanges();
Upvotes: 2