How can I fix 'Maximum call stack size exceeded' AngularJS

后端 未结 2 487
猫巷女王i
猫巷女王i 2020-11-30 11:28

I am using AngularJs and Ui-Router and I am trying to set two different home pages, one for users that are logged in and the other for users that aren\'t. But I am getting t

2条回答
  •  再見小時候
    2020-11-30 12:11

    Use $state.go("main", {}, {notify:false}); for not notify to "$stateChangeStart"event.

      // NOT authenticated - wants any private stuff
      if(shouldLogin)
      {
        $state.go("main", {}, {notify:false});
        event.preventDefault();
        return;
      }
    
    
      // authenticated (previously) comming not to root main
      if(Auth.isLoggedIn) 
      {
        var shouldGoToMain = fromState.name === ""
                          && toState.name !== "main" ;
    
        if (shouldGoToMain)
        {
            $state.go("main", {}, {notify:false});
            event.preventDefault();
        } 
        return;
      }
    

提交回复
热议问题