【问题标题】:Angularjs : $locationChangeStart checking tokenAngularjs:$locationChangeStart 检查令牌
【发布时间】:2016-05-20 08:43:59
【问题描述】:

我正在尝试检查 next 是否有 hasToken 但不工作我得到错误:

TypeError: Cannot read property 'next' of undefined

有什么想法吗?

app.js

.run(function ($rootScope, $location,$log,User) {

         $rootScope.$on("$locationChangeStart", function (event,next, current,jwtHelper) {

              if(!localStorage.token.next){

                location.path("/signin");
              }

        });

【问题讨论】:

    标签: javascript angularjs token


    【解决方案1】:

    令牌未定义

    你可以这样检查

    if(!localStorage.token || !localStorage.token.next){
                location.path("/signin");
              }
    

    【讨论】:

    • 错误,因为当我尝试重定向到家时,它被重定向到 /signin
    猜你喜欢
    • 1970-01-01
    • 2016-09-13
    • 2018-06-19
    • 2016-11-16
    • 1970-01-01
    • 2018-10-25
    • 1970-01-01
    • 1970-01-01
    • 2013-08-11
    相关资源
    最近更新 更多