0

I have this html

<div data-ng-app="myApp">
   <div ng-controller="OAuthCtrl">
       <label >
           <button class="button button-block button-positive" 

           ng-click="facebookLogin()">
               Login with Facebook
           </button>
       </label>
   </div>
</div>

and this javascript

<script type="text/javascript" src="js/framework7.js"></script>
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="js/angular/angular.min.js"></script>
<script type="text/javascript" src="js/ngCordova/dist/ng-cordova.js"></script>
<script type="text/javascript" src="cordova.js"></script>
<script>
var app = angular.module('myApp', ['ngCordova']);

app.controller("OAuthCtrl", function($scope, $cordovaOauth){
    $scope.facebookLogin = function() {

        //user your fb app Id.. 
        $cordovaOauth.facebook(fb_appId, 
        ["email"]).then(function(result) {
            alert(result.access_token);
            // results
        }, function(error) {
            alert("error");
            alert(error);
            // error
        });
    }
});
</script>

When i run the code on chrome i get this error

Error: [$injector:unpr] http://errors.angularjs.org/1.6.5/$injector/unpr?p0=%24cordovaOauthProvider%20%3C-%20%24cordovaOauth%20%3C-%20OAuthCtrl

which leads to this link

https://docs.angularjs.org/error/$injector/unpr?p0=$cordovaOauthProvider%20%3C-%20$cordovaOauth%20%3C-%20OAuthCtrl

I am following thsi tutorial to be able to login a uer using his or her own facebook account https://www.codeproject.com/Tips/1031475/How-to-Integrate-Facebook-Login-into-a-Cordova-App Where am i going wrong?.

2
  • The framework is unable to resolve $cordovaOauth in your code. Can you first make sure that all your scripts are loaded correctly and there are no errors?Please look at the console. Are there any errors? Commented Aug 6, 2017 at 21:21
  • The error showed above is the only error. Commented Aug 6, 2017 at 21:29

1 Answer 1

1

Tutorial you posted is missing some steps. You need to install cordocaOauth and inject it first.

Here are the docs:ngCordovaOauth on github

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.