gpt4 book ai didi

angularjs - 如何检测 Angular 1.5 组件路由器中的路由更改?

转载 作者:行者123 更新时间:2023-12-02 17:24:20 25 4
gpt4 key购买 nike

我在我的应用程序中使用 angular 1.5 组件路由器。有没有办法检测组件路由器中的路由更改。我想在路线更改时运行一些代码。

最佳答案

Sajeetharan 的回答是正确的,但它只适用于当前范围。如果你想要它用于每个状态更改,请像这样添加它

run.$inject = ['$rootScope', '$location', '$cookieStore', '$http'];

function run($rootScope, $location, $cookieStore, $http) {
$rootScope.$on('$locationChangeStart', function(event, next, current) {

console.log($location.path());

});
}
app.run(run);

关于angularjs - 如何检测 Angular 1.5 组件路由器中的路由更改?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39945001/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com