gpt4 book ai didi

javascript - Angularjs app.js 获取 URL

转载 作者:行者123 更新时间:2023-12-03 10:35:56 25 4
gpt4 key购买 nike

在 angularjs 中,我们在 app.js 级别上是否有任何东西来确定应用程序 URL。

我知道在应用程序内部,我们可以使用 $location.path() 来确定它,但是 app.js 我们没有 $location

基本上,需要使用 URL 参数开关启用和禁用应用程序的控制台日志记录。

想法是

http://www.test-website.com/ - 将运行但不获取console.log

http://www.test-website.com?debug=1 - 将运行并获取应用程序的 console.log。

提前致谢!!!

最佳答案

您始终可以在浏览器中的 javascript 中调用 window.location。它将返回一个包含主机名、路径名、端口和协议(protocol)以及其他属性和方法的对象。

在您的情况下,调用 window.location.search 将返回 "?debug=1"

关于javascript - Angularjs app.js 获取 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28984842/

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