我正在使用location.path(url)导航到一个页面,但我需要知道在执行其余代码之前是否已成功完成。有没有这个位置服务的回调函数,我可以利用它来放置我的代码,必须在location.path完成后执行?
$location.path("myurl");
//code to be executed after the url navigation is completed successfully
答案 0 :(得分:2)
查看$ route http://docs.angularjs.org/api/ngRoute。$ route service中定义的$routeChangeSuccess
事件。您可以使用$scope.on
方法