Angularjs 角度控制器范围变量未更新
我拥有允许通过社交网络登录的代码: 我有一个HTML页面,它调用facebookSubscrib,点击googlePlusSubscribe函数,可以工作:Angularjs 角度控制器范围变量未更新,angularjs,Angularjs,我拥有允许通过社交网络登录的代码: 我有一个HTML页面,它调用facebookSubscrib,点击googlePlusSubscribe函数,可以工作: KecooApp.controller('homeCtrl', ['$scope', '$rootScope', 'configuration', '$state', '$modal', function ($scope, $rootScope, configuration, $state, $modal) { } ]
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(在RSUserInfoParse的google部分中),但$scope.RSUserInfo已为空
如何使其工作?scope.RSInfo它不在脚本中您没有在任何地方设置$scope.RSUserInfo。它始终为空。并且您没有在getUser()中使用“user”对象函数result在controller.scope.RSInfo中注入$state两次它不在脚本中任何地方都没有设置$scope.RSUserInfo。它总是空的。并且在getUser()函数result中没有使用'user'对象,在控制器中注入$state两次。