【AngularJS】拾遗

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']; 

猜你喜欢

转载自v7sky.iteye.com/blog/2331909