$ location.path(redirecturl)和$ location.url(redirecturl)有什么区别?

Jay*_*Jay 4 javascript angularjs

我在谈论两者的setter方法而不是getter方法

对于我$ location.url 并不总是需要一段时间来重定向所以我想使用$ location.path但我想知道差异.

小智 5

所不同的是在的吸气剂$location.url()$location.path()

url()getter以形式返回路径,搜索和哈希/path?search=a&b=c#hash,而path()只返回/path.

在重定向方面,如果它只是一个路径,那么我会使用

$location.path(redirectpath).
Run Code Online (Sandbox Code Playgroud)

您可以在docs上阅读更多相关信息$location