0
我有一个处理登录到我的SPA的Angular服务。
myApp.service('loginService', ['$rootScope', '$http', '$resource', '$cookies', '$location', function($rootScope, $http, $resource, $cookies, $location) {
\t
\t this.validateEmail = function() {
\t \t $http({
\t \t \t url: myAppConfig.rootAPIUrl + 'Authenticate',
\t \t \t params: {
\t \t \t \t "playerId": $rootScope.data.emailId,
\t \t \t \t "emailAddress": $rootScope.data.emailAddress
\t \t \t },
\t \t \t method: "POST"
\t \t })
\t \t \t .then(function(response) {
\t \t \t \t if (response.data.Message == 'Success') {
\t \t \t \t \t console.log('Login is successful.');
\t \t \t \t \t $cookies.put('emailId', $rootScope.data.emailId);
\t \t \t \t \t $location.path("#/game").replace();
\t \t \t \t }
\t \t \t \t $rootScope.msg = response.data;
\t \t \t \t console.log(response.data);
\t \t \t }, function(response) {
\t \t \t \t console.log('Error in $http in controller...');
\t \t });
\t }
}]);
成功登录后,我的条件检查出if块,我得到的控制台味精,我让我的cookie设置,但位置路径“#/游戏的设定'不起作用。任何想法为什么?
你想重定向到“#/游戏”还是“/#游戏”? –
#/游戏,但即使在位置路径参数中,它也不会重定向。 – TWLATL
我不认为你需要散列在路径中,除非你将HTML5Mode设置为true,angular的$ location.path方法将为你做到这一点。你尝试过使用''/游戏'吗? –