Search code examples
nativescriptangular2-nativescriptnativescript-telerik-ui

Nativescript - WebView / HtmlView + 3rd party javascript


We have found that the nativescript ui pie chart is not going to be sufficient for our needs. From what I can tell, we might be able to do one of two things to use a third part javascript solution:

  • HtmlView
  • WebView with the source being local files

I'm not sure about 2 things with either solution:

  1. Can we load 3rd party and custom javascript
  2. Do we have the ability to listen to and trigger custom events (basically passing data/events to and from the web/html view and the containing component)

Answering those 2 questions would be huge for us, and then any potential examples would also be helpful. Thanks!


Solution

  • Yes, it's possible you could include third party scripts in WebView. But you will have to use absolute paths in Android & need a little patch work on iOS as described here Here is a Playground Sample for including images in WebView, the approach will be similar for any third party libraries.

    You may use nativescript-webview-interface plugin if you want to communicate between your JavaScript inside WebView and NativeScript runtime.