你好我有这个代码允许通过社交网络登录:
我有一个HTML页面,它点击了facebookSubscrib,点击了googlePlusSubscribe功能,有效:
KecooApp.controller('homeCtrl', ['$scope', '$rootScope', 'configuration', '$state', '$modal',
function ($scope, $rootScope, configuration, $state, $modal) {
}
]);
KecooApp.controller('signupCtrl', ['$scope', '$rootScope', 'configuration', '$state', '$modal', 'Facebook', 'googleplus', 'linkedin', '$state',
function ($scope, $rootScope, configuration, $state, $modal, Facebook, googleplus, linkedin, $state) {
$scope.RSUserInfo = {};
$scope.check = function() {
console.log($scope.RSUserInfo);
}
$scope.RSUserInfoParse = function(provider,data) {
switch(provider) {
case "facebook":
break;
case "google":
console.log(data);
RSUserInfo={};
RSUserInfo.lastname=data.family_name;
RSUserInfo.firstname=data.given_name;
return(RSUserInfo);
break;
case "linkedin":
break;
case "twitter":
break;
}
}
$scope.facebookSubscribe = function () {
// From now on you can use the Facebook service just as Facebook api says
Facebook.getLoginStatus(function (response) {
if (response.status === 'connected') {
$scope.FBloggedIn = true;
Facebook.api('/me', function (response) {
$scope.user = response;
$scope.RSUserInfo=$scope.RSUserInfoParse("facebook",response);
});
} else {
$scope.FBloggedIn = false;
Facebook.login(function (response) {
Facebook.api('/me', function (response) {
$scope.user = response;
$scope.RSUserInfo=$scope.RSUserInfoParse("facebook",response);
});
});
}
});
$state.go('app.signup-step1');
};
$scope.googlePlusSubscribe = function () {
googleplus.login().then(function (authResult) {
googleplus.getUser().then(function (user) {
console.log($scope.RSUserInfoParse("google",user,$scope.RSUserInfo));
$state.go('app.signup-step1');
});
}, function (err) {
});
};
$scope.linkedinSubscribe = function () {
data = linkedin.authorizeLinkedin();
$scope.RSUserInfo=$scope.RSUserInfoParse("linkedin",data);
}
$scope.twitterSubscribe = function () {
Digits.logIn()
.done($scope.twitterSuccess) /*handle the response*/
.fail();
$state.go('app.signup-step1');
}
$scope.twitterSuccess = function (reponse) {
$scope.RSUserInfo$scope.RSUserInfoParse("twitter",response);
$state.go('app.signup-step1');
}
}
]);
当googlePlusSubscribe被触发时,该函数被称为RSUserInfo(在谷歌部分onf RSUserInfoParse)被设置,但$ scope.RSUserInfo已经为空。
有人可以帮助我吗?