Conditional move when application first opens in angular

I am developing a mobile hybrid application using Angular and Ionic.

I have a conditional login based on a user role. During login, I get the role and based on the role that I view on the role-based page. To do this, I save my role data in LocalStorage and after logging in I check the same.

But I can’t process it $urlRouterProvider.otherwise('app/user');conditionally.

Because if I log in as user2, I closed my application. Again, if I open my application, the page should be different, but it moves on the page $urlRouterProvider.otherwise.

I tried this link but could not solve my problem.

0
source share
1 answer

As you said, you use ui-router, you can use $state.go.

Ui-router provides an event transitionStart. Here you can use your logic to go to any route you want to redirect. In this case, you will need to use the local storage value.

0
source

Source: https://habr.com/ru/post/1545537/


All Articles