UI Router conditional ui views?

后端 未结 9 1332
遥遥无期
遥遥无期 2021-01-30 21:23

I can\'t figure out a reasonable way, which doesn\'t feel like a hack, to solve this rather trivial problem.

I want a guest to see a splash page when they access the ind

9条回答
  •  耶瑟儿~
    2021-01-30 21:56

    For docs purposes, I used:

    $rootScope.$on('$stateChangeStart', function(event, toState) {
      if ((toState.name !== 'login') && (!$localStorage.nickname)) {
        event.preventDefault();
        $state.go('login');
      }
    });
    

    Using $routeChangeStart didn't work for me.

提交回复
热议问题