Reputation: 13
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);
};
});
Upvotes: 1
Views: 92
Reputation: 668
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>
Upvotes: 1