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.等于匹配符: ##"=" ...
随机推荐
- 第五周课后作业——适用于人工智能的visual studio 的创新分析
个人觉得作业布置的(2)(3)(4)(5)的顺序并不合理,我将以(5)(2)(3)(4)的顺序开展我的分析. 创新的定义是做出一些改变或创造出新的东西,既是过程,也是结果.这是一个很泛的概念,所以去问 ...
- AM335X用RGB888连接LCD如何以16位色彩模式显示图片
在AM335x中,在连接显示屏的时候,存在一个问题.这个在am335x Sillicon Errata已经提到过 在RGB888模式中 而对于RGB565模式的硬件连接 不难看出,这个RGB是反的 ...
- JavaScript学习笔记(第一天)
javascript个人笔记 JavaScript的组成 JavaScript是一种运行在客户端的脚本语言 ECMAScript 标准----js的基本的语法 DOM------Document ...
- android Build系统
http://www.ibm.com/developerworks/cn/opensource/os-cn-android-build/ android Build系统 超链接
- 【hiho一下第十二周】刷油漆
[题目链接]:http://hihocoder.com/problemset/problem/1055 [题意] [题解] 设f[x][i]表示以第x个节点为根的子树; 不选x这个节点,然后子树里面选 ...
- botot framework选择下拉框
1,下拉框不能输入文字,如图: 方法: select from list id=xxx 要选择的数据 2.下拉框可输入文字,如图: 方法: click element di=xxx ...
- 将 excel文件数据导入MySQL数据库中
第一步:先将Excel文件另存为文本文件(制表符分割) 第二步:将生成的txt文件另存,并修改编码格式utf8; 第三步:将文件放到指定位置,或自己想要的位置: G:\city.txt 第四步:避免创 ...
- elasticsearch 分页查询实现方案
1. from+size 实现分页 from表示从第几行开始,size表示查询多少条文档.from默认为0,size默认为10, 注意:size的大小不能超过index.max_result_wind ...
- CF870A Search for Pretty Integers
CF870A Search for Pretty Integers 题意翻译 给出两个整数n,m,a数组有n个数,b数组有m个数.求一个数,这个数的每一位必须在a数组和b数组中至少出现过一次,求符合条 ...
- [using_microsoft_infopath_2010]Chapter 14高级话题
本章提要: 1.剖析表单逻辑 2.从多个表单中合并数据 3.重新连接XML表单到XSN模板文件 4.在repeating table中设置默认值 5.离线填写表单的权衡