一. 获取url的相关方法:
以’https://localhost:8080/tblog.csdn.net/lixiaoyan_star/article/list/index.html/#/foo#myhash?orderby=ViewCount’为例
-
获取当前完整的url路径:
$location.absUrl();
https://localhost:8080/blog.csdn.net/lixiaoyan_star/article/list/index.html/#/foo#myhash?orderby=ViewCount -
获取当前url路径(当前url#后面的内容,包括参数和哈希值):
foo?orderby=ViewCount -
获取当前url的子路径(也就是当前url#后面的内容,不包括参数):
foo -
获取当前url的协议(比如http,https)
$location.protocol
https -
获取当前url的主机名
$location.host
// localhost -
获取当前url的端口
$location.port
8080
7.获取当前url的哈希值
$location.hash
myhash -
获取当前url的参数的序列化json对象
$location.search()
{‘orderby’:‘ViewCount’}