UI Router conditional ui views?

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

    It is used for me conditional view in ui-route

    $stateProvider.state('dashboard.home', {
            url: '/dashboard',
            controller: 'MainCtrl',
           // templateUrl: $rootScope.active_admin_template,
            templateProvider: ['$stateParams', '$templateRequest','$rootScope', function ($stateParams, templateRequest,$rootScope) {
              var templateUrl ='';
              if ($rootScope.current_user.role == 'MANAGER'){
                templateUrl ='views/manager_portal/dashboard.html';
              }else{
                templateUrl ='views/dashboard/home.html';
              }
              return templateRequest(templateUrl);
            }]
          });
    

提交回复
热议问题