您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息

AngularJS的$location使用方法分享

2024/4/25 8:12:45发布3次查看
本文主要介绍了angularjs的$location使用方法详解的相关资料,希望通过本文大家能够掌握这部分内容,需要的朋友可以参考下,希望能帮助到大家。
angularjs的$location使用方法详解
一、配置config
app.config([ '$locationprovider', function($locationprovider) {  $locationprovider.html5mode({       //设置为html5mode(模式),当为false时为hashbang模式  enabled : true,       //是否需要加入base标签,这里设置为false,设置为true时,需在html的head配置<base href="" />标签  requirebase : false  });  } ]);
注意:config里面的配置非常重要,不配置获取不到url里面的参数
二、基本用法
url:http://127.0.0.1:7001/liuxu/pages/main.html?name=5  1.获取绝对路径  $location.absurl();   //url:http://127.0.0.1:7001/liuxu/pages/main.html?name=5  2.获取主机  $location.host();  http://127.0.0.1  3.获取端口号  $location.port();  //7001  4.获取文本传输协议  $location.protocol();  http  5. 获取url参数  $location.search().name或者$location.search()['name']  //5  6.获取url  $location.url()  //:/liuxu/pages/main.html?name=5
相关推荐:
nginx location语法配置详解 location的意思 $location location重定、
angular中使用路由和$location切换视图_angularjs
高效利用angular中内置服务$http、$location等_angularjs
以上就是angularjs的$location使用方法分享的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录