angularjs – 是否有内置的方式来获取当前的URL,没有任何查询参数?

前端之家收集整理的这篇文章主要介绍了angularjs – 是否有内置的方式来获取当前的URL,没有任何查询参数?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如果我的网址是http://www.something.com/foo/bar/index.html?color=yellow\u0026amp;animal=rat,好像是:

> $location.path()将返回foo / bar / index.html
> $location.absUrl()会返回http://www.something.com/foo/bar/index.html?color=yellow\u0026amp;animal=rat
> $location.url()将返回foo / bar / index.html?color = yellow& animal = rat

有什么功能将返回http://www.something.com/foo/bar/index.html?

或者我必须使用protcol,host,port等功能来构建自己(或者剥离自己的查询参数)?

据我所知,你必须自己构建它.不是你在问如何构造它,而是那些想知道的人:
var url = $location.absUrl().split('?')[0]
原文链接:https://www.f2er.com/angularjs/143065.html

猜你在找的Angularjs相关文章