1

It is possible to display an react/angular web application on WebView component ?

I build angular(angular cli) and react application in prod mode. Next, prepared files I put inside ./assets folder. After changes inside webpack.config.js and run tns run android --bundle than nothing is shown beside of static texts.

home.component.tns.html

 <GridLayout>
     <WebView src="~/assets/seatmap/index.html"></WebView>
 </GridLayout>

home.component.tns.html

 <!doctype html>
 <html lang="en">
 <head>
 <meta charset="utf-8">
 <title>t</title>
 <base href="/">
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <link rel="icon" type="image/x-icon" href="favicon.ico">
 <link rel="stylesheet" href="styles.x.css"></head>
 <body>
     <img src="favicon.ico"> // not displayed
     <img src="./favicon.ico"> // displayed
     <app-root></app-root> // nothing is displayed
     <b>This text is displayed</b>
     <script type="text/javascript" src="runtime.x.js"></script>
     <script type="text/javascript" src="polyfills.x.js"></script>
     <script type="text/javascript" src="main.x.js"></script>
 </body>
 </html>

Javascript files are loaded. There is no problem with path. When I change src to any external web site (src="http://facebook.com") everything is ok.

1 Answer 1

0

Duplicate of NativeScript WebView loading local resources in src document

It's known issue with iOS, please refer my answer there which includes possible workarounds.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks Manoj, I have problem on Android, so similar solution should I apply like you suggested for iOS ?
For Android, the path has to be absolute.
After investigation I have found reason why web application written in Angular didn`t display on WebView component well. Just, wrong command used for build angular application. If anyone meet similar problem, try to build angular application in following command : ng build --base-href='./' --prod.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.