angularjs1-7,http,location
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script src="angular.min.js"></script> </head> <body ng-app="myApp">
<div ng-controller="firstController">
{{name}}
{{age}}
</div> <div ng-controller="secondController">
{{name}}
{{age}}
</div> <script>
var m1 = angular.module('myApp',[]);
m1.service('serviceServices01',function($http,$rootScope,$log,$filter){//请求不放在Controller,放在service里面,service层,
$rootScope.age='50';
$log.warn('jinggao');
var _name='';
this.setName=function(name){
_name=name;
};
this.getName=function(){
return _name;
};
this.getData=function(){
var myUrl ="http://www.phonegap100.com/appapi.php?a=getPortalList&catid=20&page=1&callback=JSON_CALLBACK";
return $http.jsonp(myUrl,{cache:true});
};
});
// console.log(m1);
m1.controller('firstController',['$scope','serviceServices01',function($scope,serviceServices01){
console.log(serviceServices01);
serviceServices01.getData().success(function(data){
console.log(data);
}).error(function(){
alert('shibai ');
});
$scope.name='张三';
}]);
m1.controller('secondController',['$scope','serviceServices01',function($scope,serviceServices01){
console.log(serviceServices01);
$scope.name='李四';
}]);
</script>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script src="angular.min.js"></script> </head> <body ng-app="myApp">
<div ng-controller="firstController">
{{name}}
{{age}}
</div>
<div ng-controller="secondController">
{{name}}
{{age}}
<div id="div1" style="height:400px; background:red;">
</div>
<div id="div2" style="height:400px; background:yellow;">
</div>
<div id="div3" style="height:400px; background:blue;">
</div>
<div id="div4" style="height:400px; background:red;">
</div>
</div>
<script>
var m1 = angular.module('myApp',[]);
m1.service('serviceServices01',function($http,$rootScope,$log,$filter){
$rootScope.age='50';
$log.warn('jinggao');
var _name='';
this.setName=function(name){
_name=name;
};
this.getName=function(){
return _name;
};
this.getData=function(){
var myUrl ="http://www.phonegap100.com/appapi.php?a=getPortalList&catid=20&page=1&callback=JSON_CALLBACK";
return $http.jsonp(myUrl,{cache:true});
};
}); // console.log(m1);
m1.controller('firstController',['$scope','serviceServices01',function($scope,serviceServices01){
//console.log(serviceServices01);
/*
* serviceServices01.getData().success(function(data){
console.log(data); }).error(function(){
alert('shibai ');
});
$scope.name='张三';
* */
}]);
m1.controller('secondController',['$scope','serviceServices01','$location','$anchorScroll',function($scope,serviceServices01,$location,$anchorScroll){
//console.log(serviceServices01);
$scope.name='李四';
console.log($location.absUrl()) ;
$location.hash('hello');//location用于路由管理,
$location.path('/new');
$location.path('/new').replace();
$location.search({'age':20});
$location.hash('div3');
}]);
</script>
</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 #000 solid; margin:20px;}
#parent ul{ width:200px; position:fixed; top:0; right:0;}
</style>
<script src="angular.min.js"></script>
<script>
var m1 = angular.module('myApp',[]);
m1.controller('FirstControl',['$scope','$location','$anchorScroll',function($scope,$location,$anchorScroll){
$scope.changeDiv=function(div){
$location.hash(div);
}
}]);
</script>
</head>
<body>
<div id="parent" ng-controller="FirstControl">
点击1就跳到1div,点击2就跳到2div,
<ul>
<li ng-repeat="id in [1,2,3,4,5]" ng-click="changeDiv('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>
angularjs1-7,http,location的更多相关文章
- Angularjs中使用$location获取url参数时,遇到的坑~~~
今天在开发时候,需要用到Angularjs1.4.6获取url参数,网上查了一下,有部分文章提到用$location来获取.大致方法如下 var app = angular.module('myApp ...
- angularjs1 自定义图片查看器(可旋转、放大、缩小、拖拽)
笔记: angularjs1 制作自定义图片查看器(可旋转.放大.缩小.拖拽) 2018-01-12 更新 可以在我的博客 查看我 已经封装好的 纯 js写的图片查看器插件 博客链接 懒得把 ...
- OpenCASCADE Shape Location
OpenCASCADE Shape Location eryar@163.com Abstract. The TopLoc package of OpenCASCADE gives resources ...
- 【流量劫持】SSLStrip 终极版 —— location 瞒天过海
前言 之前介绍了 HTTPS 前端劫持 的方案,虽然很有趣,然而现实却并不理想.其唯一.也是最大的缺陷,就是无法阻止脚本跳转.若是没有这个缺陷,那就非常完美了 -- 当然也就没有必要写这篇文章了. 说 ...
- 巧用location.hash保存页面状态
在我们的项目中,有大量ajax查询表单+结果列表的页面,由于查询结果是ajax返回的,当用户点击列表的某一项进入详情页之后,再点击浏览器回退按钮返回ajax查询页面,这时大家都知道查询页面的表单和结果 ...
- 2000条你应知的WPF小姿势 基础篇<78-81 Dialog/Location/WPF设备无关性>
在正文开始之前需要介绍一个人:Sean Sexton. 来自明尼苏达双城的软件工程师.最为出色的是他维护了两个博客:2,000ThingsYou Should Know About C# 和 2,00 ...
- js 页面刷新location.reload和location.replace的区别小结
reload 方法,该方法强迫浏览器刷新当前页面. 语法: location.reload([bForceGet]) 参数: bForceGet, 可选参数, 默认为 false,从客户端缓存里取当前 ...
- android获取位置location为null的问题
12:38:542016-12-23 很多人经常遇到这种问题,主要是获取到位置的信息为null,第一个主要要有权限 <uses-permission android:name="a ...
- 解决安卓微信浏览器中location.reload 或者 location.href失效的问题
在移动wap中,经常会使用window.location.href去跳转页面,这个方法在绝大多数浏览器中都不会 存在问题,但早上测试的同学会提出了一个bug:在安卓手机的微信自带浏览器中,这个是失效的 ...
- nginx之location匹配优先级和安全问题
最近一直在做location的配置,遇到优先级别问题(如有配置不当,会存在安全隐患),以下是个人的一些学习体会 一.location 匹配符 1.等于匹配符: ##"=" ...
随机推荐
- JDBC基础01
今日知识 1. JDBC基本概念2. 快速入门3. 对JDBC中各个接口和类详解 JDBC: 1. 概念:Java DataBase Connectivity Java 数据库连接, Java语言操作 ...
- BZOJ 3991 set维护dfs序
思路: set按照dfn排序 两点之间的距离可以O(logn)算出来 加一个点-> now ans+=dis(pre,now)+dis(now,next)-dis(pre-next); 删一个点 ...
- java集合的学习笔记
不知不觉也到了java集合这一章的学习,这因该是挺重要的一个章节,因为所有的程序都离不开数据,而一个良好的数据结构和算法应该是程序的灵魂吧. 今天对自己所初步了解的做一个总结: 数据结构是计算机存储. ...
- 详解sqlserver查询表索引
SELECT 索引名称=a.name ,表名=c.name ,索引字段名=d.name ,索引字段位置=d.colid ? 1 2 3 4 5 6 7 8 FROM sysindexes a ...
- 工厂模式-CaffeNet训练
参考链接:http://blog.csdn.net/lingerlanlan/article/details/32329761 RNN神经网络:http://nbviewer.ipython.org/ ...
- css table布局
表格布局有两种方式: 1.HTML Table(<table>标签)和 2. CSS Table(display:table 等相关属性). HTML Table是指使用原生的<ta ...
- (转)shiro权限框架详解05-shiro授权
http://blog.csdn.net/facekbook/article/details/54910606 本文介绍 授权流程 授权方式 授权测试 自定义授权realm 授权流程 开始构造Secu ...
- ES : 软件工程学的复杂度理论及物理学解释
系统论里面总是有一些通用的专业术语 比如复杂度.熵.焓,复杂度专门独立出来,成为复杂度理论 文章摘抄于:<非线性动力学> 刘秉政 编著 5.5 复杂性及其测度 热力学的几个专业术语 熵. ...
- VFS文件系统结构分析 与socket
本文乃fireaxe原创,使用GPL发布,可以自由拷贝,转载.但转载请保持文档的完整性,并注明原作者及原链接.内容可任意使用,但对因使用该内容引起的后果不做任何保证. 作者:fireaxe_hq@ho ...
- Jquery 研究 入口
<script type="text/javascript"> //var jQuery = function () { // console.log(jQuery.f ...