AngularJS的$location使用方法详解
网络编程 2021-07-04 17:32www.168986.cn编程入门
这篇文章主要介绍了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
如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程