I have an Angular 2 app that builds a tree using mermaidJS, which is a JS (not TS) framework.
To bind clicks on this tree to Angular events, in my ngOnInit() method I create window functions, like this :
window['myFunctionToBeCalledFromTheTree'] = () => { ...}
It all works great.
The problem that occurs, is that once any of those functions is called, Angular doesn't detect changes anymore. I have found a quick workaround with the change detector, but I have to call it everytime.
My questoin is, is there a way to give back its automatic change detection to Angular ?
NgZoneinconstructor(zone: NgZone)and wrapping your functions withwindow['myFunctionToBeCalledFromTheTree'] = () => { this.zone.run(() => { ... } }NgZone.runis meant to be run insideNgZone.runOutsideAngular- I think most code will automatically be run inside a zone, even raw JS code.ChangeDetectorRefand callchangeRef.detectChangesmanually. stackoverflow.com/questions/34827334/… -- if that doesn't work call.markForCheck()