Mert Mertce
Mert Mertce

Reputation: 1203

cordova (phonegap) works different as app and inside phonegap app

I have a web-app with angularjs. I wanted to turn it into a mobile app (android) using phonegap.

I have used phonegap build: https://build.phonegap.com

And every thing worked fine!

But this process is slow for developing. So I have installed phonegap dev app which automatically loads updates into my mobile app; but in this case mobile app works inside phonegap app on mobile.

And now, my app does not work correctly. The problem is that angularjs $routeProvider does not work (it loads the template fine, but it does not load the necessary controller):

$routeProvider
        .when('/x', {
            templateUrl: 'static/html/temp/x.html',
            controller: 'XController',
            controllerAs: 'XCtrl',
        })
        .otherwise({
            templateUrl: 'static/html/temp/y.html',
            controller: 'YController',
            controllerAs: 'YCtrl'
        });

Please again remind that my app works correctly when I install as independent mobile app; but does not work inside phonegap dev app.

I appreciate any help.

EDIT:

Somehow it started to load the YController. However, it does not execute ng-init code which is on base div of template:

<div ng-init="YCtrl.init()">
....
</div>

Upvotes: 2

Views: 162

Answers (1)

Mert Mertce
Mert Mertce

Reputation: 1203

For people who experiences similar problem:

After dedicating one entire day finally I saw the problem:

console.log()

It works for trivial inputs (ie. texts). However, for complex objects (eg. console.log($scope), $scope is defined) somehow it does not work and the worse is phonegap desktop app does not show any error log for this. It clearly seems to be a bug.

So, commenting out console.log codes solved the problem.

Upvotes: 1

Related Questions