angular $location 库的使用,主要是获取url相关信息,例如
url = http://xxx.com?#name=cccccc
$location.absUrl();
// http://xxx.com?#name=cccccc
$location.host();
// xxx.com
$location.port();
// 80
$location.protocol();
// http
$location.url();
// ?#name=cccccc
// 获取url参数
$location.search().name;
// or
$location.search()['name'];
url = http://xxx.com?#name=cccccc
$location.absUrl();
// http://xxx.com?#name=cccccc
$location.host();
// xxx.com
$location.port();
// 80
$location.protocol();
// http
$location.url();
// ?#name=cccccc
// 获取url参数
$location.search().name;
// or
$location.search()['name'];
本文详细介绍了 Angular 中 $location 服务的使用方法,包括如何通过该服务获取当前 URL 的完整信息,如绝对 URL、主机名、端口、协议以及 URL 参数等。

3888

被折叠的 条评论
为什么被折叠?



