2016-12-22 41 views
1

鑑於我的代碼:

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

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

問題是執行時anotherFunctionInController(),給我的網址仍然是舊的URL,而不是「newState」

是什麼原因?任何解決方案感謝

回答

1

試試這個,

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

這是工作!謝謝 –

+0

接受答案,然後upvote。 –