我正在使用 location.path(url) 导航到一个页面,但在执行其余代码之前我需要知道这是否已成功完成。这个位置服务是否有任何回调函数,我可以利用它来放置必须在 location.path 完成后执行的代码?
$location.path("myurl");
//code to be executed after the url navigation is completed successfully
最佳答案
查看$route http://docs.angularjs.org/api/ngRoute中定义的$routeChangeSuccess
事件.$路线服务。您可以使用 $scope.on
方法订阅它
关于javascript - angular js $location.path 回调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18582970/