angular js $ location.path回调

时间:2013-09-03 01:56:48

标签: javascript angularjs angularjs-directive angularjs-scope

我正在使用location.path(url)导航到一个页面,但我需要知道在执行其余代码之前是否已成功完成。有没有这个位置服务的回调函数,我可以利用它来放置我的代码,必须在location.path完成后执行?

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

1 个答案:

答案 0 :(得分:2)

查看$ route http://docs.angularjs.org/api/ngRoute。$ route service中定义的$routeChangeSuccess事件。您可以使用$scope.on方法

订阅它