angularjs $location 服务
2024-10-01 14:37:30
<!DOCTYPE HTML>
<html ng-app="myApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script src="angular.min.js"></script>
<script>
//对网址信息进行2次的封装。 var m1 = angular.module('myApp',[]);
m1.controller('Aaa',['$scope','$location',function($scope,$location){
var a = $location.absUrl();//网址的绝对地址(加的参数进行了编码)
$location.path('aaa/bbb/ccc').replace();
$location.hash('hello');
$location.search({'age':''});
var a = $location.protocol();//地址的协议
console.log(a);
}]); </script>
</head>
<body>
<div ng-controller="Aaa">
</div>
</body>
</html>
<!DOCTYPE HTML>
<html ng-app="myApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
#parent div{ width:300px; height:500px; border:1px # solid; margin:20px;}
#parent ul{ width:200px; position:fixed; top:; right:;}
</style>
<script src="angular.min.js"></script>
<script> var m1 = angular.module('myApp',[]);
m1.controller('Aaa',['$scope','$location','$anchorScroll',function($scope,$location,$anchorScroll){
$scope.change = function(id){
//console.log(id);
$location.hash(id);
$anchorScroll();//锚点跳转
};
}]); </script>
</head> <body>
<div id="parent" ng-controller="Aaa">
<ul>
<li ng-repeat="id in [1,2,3,4,5]" ng-click="change('div'+id)">{{id}}aaaaaaaaaa</li>
</ul>
<div ng-repeat="id in [1,2,3,4,5]" ng-attr-id="div{{id}}">{{id}}</div>
</div>
</body>
</html>
最新文章
- mybatis中表与表之间的关联
- 【转】Android Canvas绘图详解(图文)
- linux C(hello world)三个数最大和三个数最新
- 【零基础学习iOS开发】【02-C语言】05-进制
- iOS开发——UI篇OC篇&;UIView/UIWindow/UIScreen/CALayer
- Aspose.word总结
- linux下 修改配置文件的命令
- 面向对象设计模式之Facade外观模式(结构型)
- doxygen学习笔记
- HDU 3507 PrintArticle (单调队列优化)
- 【剑指offer】面试题22:栈的压入、弹出序列
- 关于 MVC 字段 默认值
- 在cad中画一条长500mm,垂直90度的线段
- Python类之类的成员
- 动态规划法(十)最长公共子序列(LCS)问题
- github上传超过100mb文件怎么办
- IntelliJ IDE 常用配置
- python笔记二
- (后端)如何将数据库的表导出生成Excel?
- ethereum发erc20token
热门文章
- [terry笔记]文件操作
- 2015 Multi-University Training Contest 3 hdu 5324 Boring Class
- 【转】 C#获取当前程序运行路径的方法集合
- Spring中 @Autowired标签与 @Resource标签 的区别(转)
- POJ2449题解
- 《Head First 设计模式》学习笔记——适配器模式 + 外观模式
- dotnet core test with NUnit
- legend---十一、thinkphp事务中if($ans1&;&;$ans2){}else{}方式和try{}catch{}方式事务操作的区别在哪里
- Linux就该这么学 20181003(第三章管道符)
- ubuntu12.04下NFS链接开发板并测试交叉编译的第一个应用