在Angular中,$state.go()没有立即执行

In Angular, $state.go() is not executed immediately

根据我的代码:

oneFunctionInController() {
    $state.go('newState')
    anotherFunctionInController()
}

anotherFunctionInController() {
    let url = $location.url()
    //do something based on url
}

问题是执行anotherFunctionInController()时,我得到的url还是原来的url,不是"newState"

这是什么原因?任何解决方案?谢谢

试试这个,

oneFunctionInController() {
$state.go('newState').then(function(){
     anotherFunctionInController();
  });
}