Divert to alternate homepage if user is not logged in using UI-Router & AngularJS

后端 未结 4 1612
暗喜
暗喜 2020-12-17 06:59

I would like to have two home pages, the first would be for users who have not logged in and the second for users that are logged in.

This is my current set up:

4条回答
  •  一向
    一向 (楼主)
    2020-12-17 07:10

    .config(function ($stateProvider,$rootScope) {
    $stateProvider
      .state('welcome', {
        url: '/',
        templateUrl: 'app/welcome/welcome.html',
        controller: 'WelcomeCtrl',
        onEnter: function() {
          if (userIsLoggedIn()) {
             $stateProvider.go('home');
          }
      });
    

    });

提交回复
热议问题