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

后端 未结 7 2237
猫巷女王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 13:09

    Yep, as suggested it looks like $state.go() doesn't work correctly in module.run().

    I found that putting the $state code in a $timeout works, e.g.

    angular.module('MainApp').run($timeout, $state, ...) {
    
        $timeout(function() {
            $state.go('main');
        });
    
    }
    

提交回复
热议问题