user3294779
user3294779

Reputation: 623

Phonegap app cannot instantiate module myApp

I'm getting this unhelpful error:

Failed to instantiate module myApp due to: {1}

Can someone please take a look at this jsfiddle and let me know if they see the issue?

http://jsfiddle.net/9Yf5V/

I also have a controller and factory set up, but I doubt it's even getting to that point and causing the issue. Just in case, here is controller code:

function mainControl($scope , $http , $log ,  facebook){
$scope.test = function(){
    facebook.getLoginStatus();
    $scope.apply();
}

$scope.console = function(){
    $scope.$log = $log;
    $scope.message = 'heeyyy!';
}
}

and here is factory code:

myApp.factory('facebook' , ['$window' , function($window){
var FB = $window.FB;

if(!FB) throw new error ('Facebook not loaded');

FB.init ({
    appId: "443530475777959",
    nativeInterface: CDV.FB,
    useCachedDialogs: false
});

return{
    getLoginStatus: function(){
        FB.getLoginStatus(function(response){
            console.log(response);
        })
    }
}

}])

Any help as well as an explanation of why myApp is not loading would be great appreciated. Thanks!

Upvotes: 0

Views: 84

Answers (1)

Roman K.
Roman K.

Reputation: 164

Just looking at the JSfiddle a few things pop out:

1) templateUrl defines the page to load in the place of the object you're using it on. so calling templateUrl: '\' causes a recursive loop pretty much.

2) controller: mainControl needs to be controller: 'mainControl' most refrences in angular are strings.

3) when is a method of $routeProvider so you can't just call it out of nowhere, typically you call $routeProvider.when() and you can chain off of that if you like.

Forked Fiddle for convienience. I've removed bits that fiddle doesn't like, and commented out your script block, adding angular-route through the external resources tab of Fiddle.

http://jsfiddle.net/7T82h/

I suspect your app can't call your controller, which would throw that error I believe.

Upvotes: 1

Related Questions