1

I just started learning angularJS using phonegap and I have a simple HTML code and a few lines of angularjs code. Everything works fine in the browser but only the HTML code works in the phonegap when I try to run it on my Android phone. Why?

<!DOCTYPE html>
<html>
<script src="C:\Users\Ghaith Haddad\Desktop\learning\learn\angular-1.5.8"></script>

    <script src="C:\Users\Ghaith Haddad\Desktop\learning\learn\www\me.js"></script>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title>AngularJS Tutorial</title>
    </head>
    <body>
        <script type="text/javascript" src="cordova.js"></script>
         <div ng-app="app3" ng-controller="ctrl1">
      <span>Values:</span>


      <input type="text" ng-model="first" />
      <input type="text" ng-model="second" />

      <h1>hello there buddy</h1>
      <button ng-click="update()">Sum</button>
      <br><br>


      {{calculation}}
     </div>

 <script>
        var app = angular.module('app3', []);

    app.controller('ctrl1', function($scope) {

    $scope.first = 1;
    $scope.second = 2; 

    $scope.update = function(){

        $scope.calculation = (+$scope.first + +$scope.second);
    };
    });
    <!-- Load the AngularJS library -->
    </script>

    <!-- Load the JS Module -->
    </body>
</html>

Here is the JS code:

    var app = angular.module('app3', []);

    app.controller('ctrl1', function($scope) {

$scope.first = 1;
$scope.second = 2; 

$scope.update = function(){

    $scope.calculation = (+$scope.first + +$scope.second);
};
});
3
  • 1
    for some reason its not showing the first few lines, it has this as well: <script src="C:\Users\Ghaith Haddad\Desktop\learning\learn\angular-1.5.8"></script> Commented Nov 15, 2017 at 0:46
  • 1
    I think your phone is not able to access your workstation harddisk -> C:\Users\Ghaith Haddad\Desktop\learning\learn\www\me.js & C:\Users\Ghaith Haddad\Desktop\learning\learn\angular-1.5.8 ;-) Commented Nov 15, 2017 at 0:55
  • i see, ok do you know how can i fix that issue? thanks Commented Nov 15, 2017 at 1:20

1 Answer 1

1

Use relative path for cordova (like "./") instead of absolute path ( ), that's way the script can't be loaded. Anyway you can debug your solution in android using chrome and attaching device or iOS using safari inspector.

Example:

<!DOCTYPE html>
<html>
  <head>
    <base href=".">
  </head>
  <body>
    <script type="text/javascript" src="bundle.js"></script>
  </body>
</html>
Sign up to request clarification or add additional context in comments.

1 Comment

there is a basic example. src should match with the correct path for this file.

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.