UI Router conditional ui views?

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

    The way I've done this is pretty simple. I made one for our A/B testing strategy. This is the gist:

    resolve: {
       swapTemplate: function(service) {
          // all of this logic is in a service
          if (inAbTest) {
             this.self.templateUrl = '/new/template.html';
          }
       }
       ... other resolves
    }
    

    This gets called before the template is downloaded and therefor you're allowed to swap out the template url.

提交回复
热议问题