一、配置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
相关文章
- AngularJS的$location基本用法和注意事项
- 微信小程序组件详解:text 和 rich-text 组件的基本用法
- Python中Celery 的基本用法以及Django 结合 Celery 的使用和实时监控进程
- 青花瓷(charles)的基本使用和注意事项
- 关于在Android Studio环境下使用AIDL的基本步骤和常见注意事项
- java中的 FileWriter类 和 FileReader类的一些基本用法
- PHP运行的注意事项和基本语法规范-🎶(6)在html中插入PHP
- css3 2D动画的基本用法和介绍
- Linux(centos8)下的yum的基本用法和实例 Linux配置yum源
- OnsenUI和AngularJS配合搭建混合应用的基本步骤