Reputation:
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?.
Upvotes: 0
Views: 51
Reputation: 1718
Tutorial you posted is missing some steps. You need to install cordocaOauth and inject it first.
Here are the docs:ngCordovaOauth on github
Upvotes: 1