Html 错误:[$injector:unpr]未知提供程序:UserServiceProvider<;-用户服务<;-fbLoginCtrl
我有一个带有Facebook登录按钮的ionic页面和一个带有Facebook登录控制器的模块 控制器是Html 错误:[$injector:unpr]未知提供程序:UserServiceProvider<;-用户服务<;-fbLoginCtrl,html,angularjs,facebook,authentication,ionic-framework,Html,Angularjs,Facebook,Authentication,Ionic Framework,我有一个带有Facebook登录按钮的ionic页面和一个带有Facebook登录控制器的模块 控制器是 module.controller('fbLoginCtrl', function($scope, $state, $q, UserService, $ionicLoading) { // This is the success callback from the login method var fbLoginSuccess = function(response)
module.controller('fbLoginCtrl', function($scope, $state, $q, UserService, $ionicLoading) {
// This is the success callback from the login method
var fbLoginSuccess = function(response) {
if (!response.authResponse){
fbLoginError("Cannot find the authResponse");
return;
}
var authResponse = response.authResponse;
getFacebookProfileInfo(authResponse)
.then(function(profileInfo) {
// For the purpose of this example I will store user data on local storage
UserService.setUser({
authResponse: authResponse,
userID: profileInfo.id,
name: profileInfo.name,
email: profileInfo.email,
picture : "http://graph.facebook.com/" + authResponse.userID + "/picture?type=large"
});
$ionicLoading.hide();
$state.go('app.home');
}, function(fail){
// Fail get profile info
console.log('profile info fail', fail);
});
};
// This is the fail callback from the login method
var fbLoginError = function(error){
console.log('fbLoginError', error);
$ionicLoading.hide();
};
// This method is to get the user profile info from the facebook api
var getFacebookProfileInfo = function (authResponse) {
var info = $q.defer();
facebookConnectPlugin.api('/me?fields=email,name&access_token=' + authResponse.accessToken, null,
function (response) {
console.log(response);
info.resolve(response);
},
function (response) {
console.log(response);
info.reject(response);
}
);
return info.promise;
};
//This method is executed when the user press the "Login with facebook" button
$scope.facebookSignIn = function() {
facebookConnectPlugin.getLoginStatus(function(success){
if(success.status === 'connected'){
// The user is logged in and has authenticated your app, and response.authResponse supplies
// the user's ID, a valid access token, a signed request, and the time the access token
// and signed request each expire
console.log('getLoginStatus', success.status);
// Check if we have our user saved
var user = UserService.getUser('facebook');
if(!user.userID){
getFacebookProfileInfo(success.authResponse)
.then(function(profileInfo) {
// For the purpose of this example I will store user data on local storage
UserService.setUser({
authResponse: success.authResponse,
userID: profileInfo.id,
name: profileInfo.name,
email: profileInfo.email,
picture : "http://graph.facebook.com/" + success.authResponse.userID + "/picture?type=large"
});
$state.go('app.home');
}, function(fail){
// Fail get profile info
console.log('profile info fail', fail);
});
}else{
$state.go('app.home');
}
} else {
// If (success.status === 'not_authorized') the user is logged in to Facebook,
// but has not authenticated your app
// Else the person is not logged into Facebook,
// so we're not sure if they are logged into this app or not.
console.log('getLoginStatus', success.status);
$ionicLoading.show({
template: 'Logging in...'
});
// Ask the permissions you need. You can learn more about
// FB permissions here: https://developers.facebook.com/docs/facebook-login/permissions/v2.4
facebookConnectPlugin.login(['email', 'public_profile'], fbLoginSuccess, fbLoginError);
}
});
};
})
我的索引页按钮是
<div class="button-bar" ng-controller="fbLoginCtrl">
<button class="button button-positive icon icon-left ion-social-facebook waves-effect waves-light" ng-click="facebookSignIn()">Facebook</button>
</div>
脸谱网
当我试图在模拟器中运行它时,我得到了这个错误
错误:[$injector:unpr]未知提供程序:UserServiceProvider可能您没有获得
facebookConnectPlugin
插件。在运行模拟器之前,请尝试运行bower安装
或npm安装
如果你还没有安装它,请访问以获取说明通常,当您注入的依赖项未定义或未正确注入时,会发生此类错误。@MuhammedNeswine我知道这可能是问题所在,但我不知道如何解决它我遵循了指南,但我认为这是旧的原因,因为我在安装时不断出错,如未找到目录或错误在
--target android-19
你能告诉我在哪里可以找到关于如何在ionic应用程序中实现Facebook身份验证的完整教程吗?谢谢你的帮助