这是我要解决的问题。
我有一个window.open
功能打开一个小窗口,供用户使用他们选择的社交网络登录/注册。用户登录后,我希望关闭小窗口并$scope
更新原始父窗口,而无需刷新页面。
我这样做的全部目标是不中断用户对网站的体验。该站点是一个音乐站点,因此如果用户正在听一首歌曲并且页面重新加载,他们将失去在站点中的位置并最终不开心。
我想就是这样。
app.controller('MainCtrl', [
$scope.loginTrigger = function() {
window.open("http://www.url.com/login", "_blank", "toolbar=yes, scrollbars=yes, resizable=no, top=0, left=100, width=1000, height=600");
}
if ($location.hash()) {
$http({
method: 'POST',
url: '/users/oauth_complete/',
data: data,
}).success(function(data){
if(!data.success){
$window.location.href = '/usersetup';
}else {
$scope.LoggedInUser = data;
storage.set('LoggedInUser', data);
//Here is my current code: Small window closes and the parent page reloads but I don't want to use refresh as it will interrupt the user experience.
window.close();
window.opener.location.reload();
}
},"JSON");
};
}]);