UI Router conditional ui views?

后端 未结 9 1173
遥遥无期
遥遥无期 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:47

    My Solution:

    angular.module('myApp')
    .config(function ($stateProvider) {
        $stateProvider
            .state('main', {
                url: '/',
                controller: function (Auth, $state) {
                    if (someCondition) {
                        $state.go('state1');
                    } else {
                        $state.go('state2');
                    }
                }
            });
    });
    

    where state 1 and state 2 are defined elsewhere.

提交回复
热议问题