7

I am creating an Angular + Cordova application and it works great in the browser.

The issue what I am facing is that when I try to include cordova.js file, the app goes blank when loaded on a device. I have done some research and it turns out to be something with cordova.exec and zone.js used in Angular causing the issue.

I would like a solution on how to properly include cordova.js in an Angular based project.

Cordova

android 8.0.0
ios 5.0.1

Angular

@angular-devkit/architect         0.801.1
@angular-devkit/build-angular     0.801.1
@angular-devkit/build-optimizer   0.801.1
@angular-devkit/build-webpack     0.801.1
@angular-devkit/core              8.1.1
@angular-devkit/schematics        8.1.1
@ngtools/webpack                  8.1.1
@schematics/angular               8.1.1
@schematics/update                0.801.1
rxjs                              6.4.0
typescript                        3.4.5
webpack                           4.35.2
Nidhin Joseph
  • 9,981
  • 4
  • 26
  • 48

1 Answers1

1

Try these: This youtube video says we need to change the <base href="/"> in your index.html to <base href="./">. If that doesn't work, try changing your type="module" to type="text/javascript" in your index.html.

Philip
  • 638
  • 1
  • 8
  • 22
  • this is not the issue with base url. its with change detection – Nidhin Joseph Aug 02 '19 at 01:54
  • Okay, please let me know if you figure out how to correctly include cordova.js in your project as I am also working on a Cordova-Angular app – Philip Aug 02 '19 at 02:30
  • 1
    yep, the issue occurs only on iOS. have a look at this https://github.com/angular/angular/issues/22509 – Nidhin Joseph Aug 02 '19 at 02:34
  • Yes, thank you! I found a patch on your link (see https://weblogs.thinktecture.com/thomas/2017/02/cordova-vs-zonejs-or-why-is-angulars-document-event-listener-not-in-a-zone.html) - although I guess you meant the issue only occurs in Android – Philip Aug 02 '19 at 04:26
  • Not really, the workaround did not work and the issue is actually only on iOS. – Nidhin Joseph Aug 04 '19 at 23:25