Javascript library not working on Device

I am using the BigNumber library of MikeMcl to handle my needs for big numbers. I use this library in an Ionic/Angular project.

As explained on Github, the way to install and use this library is to include a script tage in your html:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>

    <!-- compiled css output -->
    <link href="css/ionic.app.min.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

    <!-- ionic/angularjs js -->
    <script src="lib/ionic/js/ionic.bundle.min.js"></script>

    <!-- cordova script (this will be a 404 during development) -->
    <script src="lib/ngCordova/dist/ng-cordova.min.js"></script>
    <script src="cordova.js"></script>

    <!-- ********* BIGNUMBER library ********* -->
    <script src='lib/bignumber.js/bignumber.min.js'></script>    

    <script src="js/app.js"></script>
    <script src="js/controllers.js"></script>
    <script src="js/services.js"></script>

  </head>
  <body ng-app="starter">
    <ion-nav-view></ion-nav-view>
  </body>
</html>

Now in my code, I can use this library as for instance:

x = new BigNumber(123.4567)
y = BigNumber('123456.7e-3')
z = new BigNumber(x)
x.equals(y) && y.equals(z) && x.equals(z)      // true

I tested this and it works fine on Chrome and on Safari (even on device).

But when I install the app on my phone, using Phonegap Build, the app does not work anymore (I checked that this library is the cause by removing the BigNumber syntaxes from my code). Moreover, the Angular in the app just crashes and shows for instance {{variableName}} and nothing is working.

Because I develop in a cloud environment, I did try to debug the app using the Safari Developer Debug Console on a mac (by plugging my phone with an USB to the mac and then enabling Developer tools in Safari).

However, no errors were found with exception of one:

file not found: "path/to/ionic/lib/js/angular.min.js.map" 404

But this does not look to me related to the problem.

What is going on? How can I still use this javascript library on my device?


Source: ios

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.