gpt4 book ai didi

javascript - 无法使用 Angular 中的 $location 服务更改 URL 路径

转载 作者:行者123 更新时间:2023-11-27 23:10:03 25 4
gpt4 key购买 nike

我尝试使用 $location.url 服务更改整个 url 路径,但它没有正确更新路径。

例如我的路径是

http://localhost:64621/module/commercial/#/company/98163780-4fa6-426f-8753-e05a67d48e54

我想将其更改为

http://localhost:64621/module/sales/#/sales-company/98163780-4fa6-426f-8753-e05a67d48e54

我的 $location.url 代码是

$location.url('/module/sales/#/sales-company/98163780-4fa6-426f-8753-e05a67d48e54')

但它仍然无法正常工作,它没有以正确的方式重定向,请让我知道如何使用 $location 服务实现上述功能。

最佳答案

您应该使用 $window.location.href 来实现此目的,请参阅 documentation

What does it not do?
It does not cause a full page reload when the browser URL is changed. To reload the page after changing the URL, use the lower-level API, $window.location.href.

关于javascript - 无法使用 Angular 中的 $location 服务更改 URL 路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36262738/

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