有条件的导航应用程序时,会打开角度在第一次 [英] Conditional Navigate when app opens for the first time in angular

查看:111
本文介绍了有条件的导航应用程序时,会打开角度在第一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发具有角和离子帮助移动应用混合

I am developing mobile hybrid app with the help of Angular and Ionic.

我有一个基于用户角色有条件登录。在登录时我得到角色,根据角色要前往的基于角色的页面。
对于这个我在localStorage的保存我的角色数据,并登录后,我检查是一样的。

I have conditional login based on user role. On the login time i am getting role and based on role i am navigating to the role based page. For this i am saving my role data in LocalStorage and after login i am checking the same.

但我不能够处理 $ urlRouterProvider.otherwise(应用/用户); 有条件

由于所以我关闭我的应用程序,如果我登录为用户2。同样,如果我打开我的应用程序的页面应该是不同的,但它是在浏览 $ urlRouterProvider.otherwise

Because if i am login as a user2 so i closed my app. Again if i am opening my app the page should be different but it is navigating on $urlRouterProvider.otherwise page.

我试过这个<一个href=\"http://stackoverflow.com/questions/24349977/conditional-page-display-when-application-opens-for-the-first-time\">link但不能够解决我的问题。

I tried this link but not able to solve my problem.

推荐答案

当U说你正在使用 UI路由器,您可以用 $ state.go

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

UI路由器提供了 transitionStart 事件。在这里,你可以用你的逻辑去要重定向任何路线。你将不得不在这种情况下使用本地存储的价值。

Ui-router provides transitionStart event. Here you can use your logic to go to whichever route you want to redirect. You will have to use your local storage value in this event.

这篇关于有条件的导航应用程序时,会打开角度在第一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆