0

I need to make a call from window.external on angular 2 and expose a json as parameter.

Something like the example below.

C#

[System.Runtime.InteropServices.ComVisibleAttribute(true)]
   public class ScriptInterface
   {
      void callMe(string json)
      {
       … // Do something interesting
      }
   } 



   webBrowser1.ObjectForScripting = new ScriptInterface();

Angular 2

window.external.callMe(json);

Anyone have any suggestions?

Thanks

1 Answers1

0

One way to achieve that is by event :

  • your external function emits an event

  • Angular application listens to this event and take appropriate action. (for example notify a service, and this service will itself transmit a notification to your components that need to be affected and have subscribed to it, or as another example use a HostListener directive)

For a concret example:

https://www.javascripttuts.com/global-events-and-event-delegation-in-angular-2/

or

Detect Click outside element in angular 4 using directives

Pac0
  • 21,465
  • 8
  • 65
  • 74