我正在使用facebook集成。这里我写了注销代码,在注销成功后进入登录状态。但是我在注销状态下遇到问题。注销只有当我刷新页面时才会工作,这样刷新后只显示注销成功和进入登录状态。没有刷新页面如何从facebook注销并更改为登录状态? 这是我的代码:
var app = angular.module("logApp", [])
.controller("logCtrl", function ($scope, $http, $state, $window) {
window.fbAsyncInit = function () {
FB.init({
appId: "214238962389773",
status: true,
cookie: true,
xfbml: true,
oauth: true
});
FB.getLoginStatus(function (response) {
if (response && response.status === 'connected') {
FB.logout(function (response) {
$window.location.reload();
// FB.Auth.setAuthResponse(null, 'unknown');
/** Afer logout, Refresh the Page **/
console.log('Logout Successfully.');
document.getElementById('currentStatus').innerHTML = 'Logout from facebook Successfully.';
$window.location.reload();
$state.go("login");
//document.location.href='/';
/** Afer logout, Refresh the Page **/
});
} else {
// document.location.href = '/login';
document.getElementById('currentStatus').innerHTML = 'You are NOT LOGIN in Facebook.';
console.log('You are not login in Facebook.')
}
});
};
(function (d) {
var js, id = 'facebook-jssdk';
if (d.getElementById(id)) {
return;
}
js = d.createElement('script');
js.id = id;
js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
})
<div class="col-sm-3 col-xs-2 col-md-1" style="float:right">
<span class=" glyphicon glyphicon-log-out " style="margin-right:0px;color:white;font-size:20px;margin-top:10px;cursor:pointer" data-ng-show="$state.includes( 'chatPage') " ui-sref="logout "></span>
</div>