ui-router: default route based on user role

后端 未结 2 1436
生来不讨喜
生来不讨喜 2021-02-09 19:09

I\'m using UI router in my project. The home page of my application consists of 4 tabs, each routing to a different template. This is my current routing code, im using a forEach

2条回答
  •  孤城傲影
    2021-02-09 19:55

    If the link of the default state is same for each role e.g /user/home for both admin and user. One thing we can do is to show different html templates in the default state of the app based on roles. ui-router provides @stateProvider service which has properties templateProvider and ControllerProvider properties. We can use them to figure out which template and controller we want to use for same default state. Here is the documentation link.

提交回复
热议问题