浏览器后退按钮使用户可以在Angular Js中再次自动登录?

时间:2018-04-01 08:44:43

标签: angularjs

我正在努力,登录模块。在我的用户登录和点击退出按钮后,用户成功注销,但点击浏览器后退按钮后,用户将自动登录,我使用localStorage存储用户信息,我使用$ rootScope。$ on(' $ locationChangeSuccess'但现在它正在运作。那么,有谁能告诉我如何解决这个问题?



var app= angular.module("angularTable", []);
app.controller("productController",  ['$rootScope', '$scope','$location', function($scope, $rootScope, $location)    {
     
     }]);


app.run(function($rootScope, $route, $location){
  $rootScope.$on('$locationChangeSuccess', function() {
    $rootScope.actualLocation = $location.path();
  });        

  $rootScope.$watch(function () {return $location.path()}, function (newLocation, oldLocation) {
    if($rootScope.actualLocation === newLocation) {
        alert('Why did you use history back?');
    }
  });
});




1 个答案:

答案 0 :(得分:0)

使用ui-state路由器插件的示例,

>>> lst = ['foo', 'bar', '!test', '!baz!', 'hello', 'world!', 'word']
>>> to_sublists(lst)
['foo', 'bar', ['test', ['baz'], 'hello', 'world'], 'word']

})