Angular 2 – communication of typescript functions with external js libraries
Just fire a custom event using dispatchEvent. In Angular you can listen by adding to any component that is actually added to the DOM: in any template: <div (window:custom-event)=”updateNodes($event)”> or in the components class: @HostListener(‘window:custom-event’, [‘$event’]) updateNodes(event) { … } or in the @Component() or @Directive() annotation: @Component({ selector: ‘…’, host: {‘(window:custom-event)’:’updateNodes($event)’} }) where custom-event … Read more