nativescript-webview-interface icon indicating copy to clipboard operation
nativescript-webview-interface copied to clipboard

How to get this work with angular app in webview?

Open Liranius opened this issue 8 years ago • 4 comments
trafficstars

I have an angular web app. For some reason, I have to get it work within nativescript app.

I see your demo run a local html in webview with your plugin enabled. However, it is suggested to load a module inside angular rather than using

Liranius avatar Jul 19 '17 14:07 Liranius

I also tried to accomplish this with Angular + Typescript What I did was to create a d.ts file to export the class and made the JS file available inside my bundle for scripts. On the component where I wanted to enable the comunication, was just let wbInterface: NSWebViewInterface.WebViewInterface = (<any>window).nsWebViewInterface;

mbondoso avatar Sep 07 '17 10:09 mbondoso

I ended up just porting it to typescript for our angular app then imported it similarly @mbondoso. Uploaded it as a gist here if anyone wants to take the same path. I also added an off method to remove event listeners.

// setup global NsWebviewInterface
const nsWebViewInterface = new NsWebViewInterface();
(window as any).nsWebViewInterface = nsWebViewInterface;

@Component({
 //...

llwt avatar Nov 15 '17 18:11 llwt

Just updated everything in project (tns to 3.4.0, angular to 5, etc) and now webview is not being displayed. Any ideas? I see this in console: JS: ERROR TypeError: Cannot read property 'natiescriptwebviewinterface' of undefined

carrbrpoa avatar Jan 05 '18 19:01 carrbrpoa

I want to call

const nsWebViewInterface = new NsWebViewInterface(); (window as any).nsWebViewInterface = nsWebViewInterface;

thanks!

Now, how do I make a function that will be called from ns app?

sebamed avatar Sep 23 '18 17:09 sebamed