module.run() and $state.go() angularJS

后端 未结 7 2239
猫巷女王i
猫巷女王i 2021-02-12 12:38

I might have some kind of missunderstanding. Im using angular ui router and i have the next issue:

I have the next State provider:

angular
.module(\'Main         


        
7条回答
  •  深忆病人
    2021-02-12 12:42

    I am having exactly the same problem.
    I am using ionic to build a cross-platform mobile app.
    I have logic like --> if the user is already logged in. redirect to the main page, otherwise redirect to login page

    if(isLogin("userId")){
        $state.go("main");
    }else{
        $state.go("login");
    }
    

    This work perfectly on Android but crash occasionally on IOS. After some investigation and research. I use $location.path instead of $state.go and everything works fine.

    if(isLogin("userId")){
        $location.path("/main");
    }else{
        $location.path("/login");
    }
    

    Hope this help you solve your problem.

提交回复
热议问题