1

I'm working on an Angular 2 app that is going to be integrated into a larger struts/jsp based application framework. In navigating out of the Angular 2 SPA and to another part of the app, I'll need to call an existing javascript function that is accessible in the window from the typescript code.

Does anyone know if this is possible and have a good example of how to do it? I looked into renderer.invokeElementMethod, but that appears to apply to elements inside of the SPA, and not able to target the outer dom (ie: window or document)

jspriggs
  • 403
  • 1
  • 5
  • 15
  • 1
    Have you tried this `declare var window: any; window.myMethod();`? – yurzui Sep 21 '16 at 15:42
  • In a manner it did. It's a workable solution for now. Thanks! – jspriggs Sep 21 '16 at 16:10
  • This might help with your problem http://stackoverflow.com/questions/36997625/angular-2-communication-of-typescript-functions-with-external-js-libraries/36997723#36997723 – isawk Oct 19 '16 at 09:47
  • @jspriggs how is your Angular2 App integrated with the large struts/jsp app? I integrate my Angular2 App within an tag on my large PHP app's html page. And I tried to use `window.methodCall()`to call external JS functions in my Angular2 App, but got cross origin error. I think that's because my large app and my angular app run on different domain. Do you have any thoughts? – Ng2-Fun May 18 '17 at 18:16

0 Answers0