简体   繁体   English

angular js $ location.path回调

[英]angular js $location.path callback

I am using location.path(url) to navigate to a page, but I need to know if this has successfully completed before executing rest of the code. 我正在使用location.path(url)导航到一个页面,但我需要知道在执行其余代码之前是否已成功完成。 is there any callback function for this location service that I can utilize to place my code that must be executed after the location.path has been completed? 有没有这个位置服务的回调函数,我可以利用它来放置我的代码,必须在location.path完成后执行?

    $location.path("myurl");
    //code to be executed after the url navigation is completed successfully

Look at the $routeChangeSuccess event defined in $route http://docs.angularjs.org/api/ngRoute .$route service . 查看$ route http://docs.angularjs.org/api/ngRoute。$ route service中定义的$routeChangeSuccess事件。 You can subscribe to it using $scope.on method 您可以使用$scope.on方法订阅它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM