我有一个处理登录SPA的Angular服务。
myApp.service('loginService', ['$rootScope', '$http', '$resource', '$cookies', '$location', function($rootScope, $http, $resource, $cookies, $location) {
this.validateEmail = function() {
$http({
url: myAppConfig.rootAPIUrl + 'Authenticate',
params: {
"playerId": $rootScope.data.emailId,
"emailAddress": $rootScope.data.emailAddress
},
method: "POST"
})
.then(function(response) {
if (response.data.Message == 'Success') {
console.log('Login is successful.');
$cookies.put('emailId', $rootScope.data.emailId);
$location.path("#/game").replace();
}
$rootScope.msg = response.data;
console.log(response.data);
}, function(response) {
console.log('Error in $http in controller...');
});
}
}]);

成功登录后,我的条件会在if块中查看,我会收到控制台消息,我会设置我的cookie,但是设置了#'#/ game'的位置路径。不起作用。关于为什么的任何想法?