欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

AngularJS的$location使用方法詳解

 更新時(shí)間:2017年10月19日 14:48:27   作者:柳絮飛祭奠  
這篇文章主要介紹了AngularJS的$location使用方法詳解的相關(guān)資料,希望通過本文大家能夠掌握這部分內(nèi)容,需要的朋友可以參考下

AngularJS的$location使用方法詳解

一、配置config

app.config([ '$locationProvider', function($locationProvider) { 
$locationProvider.html5Mode({ 
     //設(shè)置為html5Mode(模式),當(dāng)為false時(shí)為Hashbang模式 
enabled : true, 
     //是否需要加入base標(biāo)簽,這里設(shè)置為false,設(shè)置為true時(shí),需在html的head配置<base href="" />標(biāo)簽 
requireBase : false 
}); 
} ]); 


注意:config里面的配置非常重要,不配置獲取不到url里面的參數(shù)

二、基本用法

url:http://127.0.0.1:7001/liuxu/pages/main.html?name=5 
1.獲取絕對(duì)路徑 
$location.absUrl();  
//url:http://127.0.0.1:7001/liuxu/pages/main.html?name=5 
2.獲取主機(jī) 
$location.host(); 
http://127.0.0.1 
3.獲取端口號(hào) 
$location.port(); 
//7001 
4.獲取文本傳輸協(xié)議 
$location.protocol(); 
http 
5. 獲取url參數(shù) 
$location.search().name或者$location.search()['name'] 
//5 
6.獲取url 
$location.url() 
//:/liuxu/pages/main.html?name=5

如有疑問請(qǐng)留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

相關(guān)文章

最新評(píng)論