<!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的更多相关文章

  1. Angularjs中使用$location获取url参数时,遇到的坑~~~

    今天在开发时候,需要用到Angularjs1.4.6获取url参数,网上查了一下,有部分文章提到用$location来获取.大致方法如下 var app = angular.module('myApp ...

  2. angularjs1 自定义图片查看器(可旋转、放大、缩小、拖拽)

    笔记: angularjs1 制作自定义图片查看器(可旋转.放大.缩小.拖拽) 2018-01-12 更新  可以在我的博客  查看我 已经封装好的 纯 js写的图片查看器插件    博客链接 懒得把 ...

  3. OpenCASCADE Shape Location

    OpenCASCADE Shape Location eryar@163.com Abstract. The TopLoc package of OpenCASCADE gives resources ...

  4. 【流量劫持】SSLStrip 终极版 —— location 瞒天过海

    前言 之前介绍了 HTTPS 前端劫持 的方案,虽然很有趣,然而现实却并不理想.其唯一.也是最大的缺陷,就是无法阻止脚本跳转.若是没有这个缺陷,那就非常完美了 -- 当然也就没有必要写这篇文章了. 说 ...

  5. 巧用location.hash保存页面状态

    在我们的项目中,有大量ajax查询表单+结果列表的页面,由于查询结果是ajax返回的,当用户点击列表的某一项进入详情页之后,再点击浏览器回退按钮返回ajax查询页面,这时大家都知道查询页面的表单和结果 ...

  6. 2000条你应知的WPF小姿势 基础篇<78-81 Dialog/Location/WPF设备无关性>

    在正文开始之前需要介绍一个人:Sean Sexton. 来自明尼苏达双城的软件工程师.最为出色的是他维护了两个博客:2,000ThingsYou Should Know About C# 和 2,00 ...

  7. js 页面刷新location.reload和location.replace的区别小结

    reload 方法,该方法强迫浏览器刷新当前页面. 语法: location.reload([bForceGet]) 参数: bForceGet, 可选参数, 默认为 false,从客户端缓存里取当前 ...

  8. android获取位置location为null的问题

      12:38:542016-12-23 很多人经常遇到这种问题,主要是获取到位置的信息为null,第一个主要要有权限 <uses-permission android:name="a ...

  9. 解决安卓微信浏览器中location.reload 或者 location.href失效的问题

    在移动wap中,经常会使用window.location.href去跳转页面,这个方法在绝大多数浏览器中都不会 存在问题,但早上测试的同学会提出了一个bug:在安卓手机的微信自带浏览器中,这个是失效的 ...

  10. nginx之location匹配优先级和安全问题

    最近一直在做location的配置,遇到优先级别问题(如有配置不当,会存在安全隐患),以下是个人的一些学习体会 一.location 匹配符 1.等于匹配符:      ##"=" ...

随机推荐

  1. JDBC基础02

    今日知识 1. sql注入问题2. jdbc批处理3. 事务 SQL注入问题解决 1.什么是sql注入. * 用户通过相关的特殊关键字sql语句非法访问数据库 *例如: Xxx(' or '1'='1 ...

  2. C - Game With Sticks

    Problem description After winning gold and silver in IOI 2014, Akshat and Malvika want to have some ...

  3. Delete, drop table, truncate之间的区别

    Delete, drop table, truncate有什么区别? delete 删除表中数据,可以删除一条或多条记录,可以回滚,记录操作日记,是DML truncate table,一次性清空表中 ...

  4. CSS简单入门

    - Java攻城狮学习路线 - 一. 什么是CSS CSS指层叠样式表(Cascading Style Sheets),定义如何显示HTML元素 二. CSS语法 /* 选择器 { 声明: 声明:}* ...

  5. IE浏览器 ajax传参数值为中文时出现乱码的解决方案

    找了很多方法,发现就这个方法简单.直接.方便,直接推荐哦! 在汉字的位置加个保护措施:encodeURIComponent(parentid) 举个栗子>>> $.ajax({    ...

  6. axis2服务器搭建

    一. axis2服务器搭建 简单起见, axis2r搭建采用较为简单的一种方式, 即将服务类和services.xml打成.aar包发布. 1. 下载部署axis2 http://axis.apach ...

  7. Nginx代码风格图示

    Nginx代码风格图示 (100%) 一.基本原则 K&R编码风格(偏BSD子类). 每行不能超过80列. 不用TAB对齐,用空格. 默认对齐单元是4个空格. 除宏定义外,字母均为小写,单词间 ...

  8. 带你认识闻名遐迩的ZBrush

    ZBrush®是一款数字雕刻和绘画软件,它以其强大的功能和直观的工作流程彻底改变了3D行业.ZBrush 4R8是目前最新版本,它秉持一贯的简洁界面风格,给如今的数字艺术工作者提供了世界领先的工具.它 ...

  9. bootstrap中container 类和container-fluid类的区别container类所谓的自适应也是通过margin的改变来完成,container-fluid类的百分百宽度是指在固有的15px的padding前提下宽度总是当前视口的宽度。

    container 类和container-fluid类的区别体现在是否有随视口宽度改变的margin存在. container类所谓的自适应也是通过margin的改变来完成,container-fl ...

  10. codevs 2800 送外卖 floyd + Tsp

    简单的状压动归 #include<cstdio> #include<algorithm> using namespace std; const int N=17; const ...