Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get this work with angular app in webview? #16

Open
Liranius opened this issue Jul 19, 2017 · 4 comments
Open

How to get this work with angular app in webview? #16

Liranius opened this issue Jul 19, 2017 · 4 comments

Comments

@Liranius
Copy link

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 <script> tag to load it globally. So is there a more 'angular' way to get your plugin to work with angular web app?

@mbondoso
Copy link

mbondoso commented Sep 7, 2017

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;

@llwt
Copy link

llwt commented Nov 15, 2017

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({
 //...

@carrbrpoa
Copy link

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

@sebamed
Copy link

sebamed commented Sep 23, 2018

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants