<!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. shp系列(四)——利用C++进行Shx文件的读(打开)

    1.shx文件的基本情况 shx文件又叫索引文件,主要包含坐标文件的索引信息,文件中每个记录包含对应的坐标文件记录距离坐标文件的初始位置的偏移量.通过索引文件可以很方便地在坐标文件中定位到指定目标的坐 ...

  2. BZOJ 1196 二分+Kruskal

    思路: 二分答案 判一下能不能加 //By SirisuRen #include <cstdio> #include <cstring> #include <algori ...

  3. MSDN性能分析相关网站收集

    Visual Studio 性能分析初学者指南 | Microsoft Docshttps://docs.microsoft.com/zh-cn/visualstudio/profiling/begi ...

  4. JS中数组的一些笔记

    今天工作时碰到一个需求,有两个数组arrayChild, arrayFather, 要求: 1.往数组arrayChild中放入一个元素: 2.将当前的数组arrayChild放入arrayFathe ...

  5. 三维建模:方法之CSG与B-Rep比较

    源自于百度百科:实体造型--- 三维模型特征表示方法: 计算机中表示三维形体的模型,按照几何特点进行分类,大体上可以分为三种:线框模型.表面模型和实体模型.如果按照表示物体的方法进行分类,实体模型基本 ...

  6. Boost锁~临界区保护和临界资源共享

    前言: 除了thread,boost::thread另一个重要组成部分是mutex,以及工作在mutex上的boost::mutex::scoped_lock.condition和barrier,这些 ...

  7. MongoDB 学习笔记(五):固定集合、GridFS文件系统与服务器端脚本

    一.count.distinct与group 1.count函数:查询文档数,如下图: 2.distinct:去重,用法:db.runCommand({distinct:"集合名" ...

  8. 【前端】CSS隐藏元素的方法和区别

    CSS隐藏元素的方法和区别 <!DOCTYPE html> <html lang="en"> <head> <meta charset=& ...

  9. python数据分析------文本挖掘(jieba)

    1.import jieba jieba的cut函数有三个模式:全模式.精准模式.搜索引擎模式 1 精确模式,试图将句子最精确地切开,适合文本分析: 2 全模式,把句子中所有的可以成词的词语都扫描出来 ...

  10. nyoj56-阶乘因式分解(一)

    56-阶乘因式分解(一) 内存限制:64MB时间限制:3000msSpecial Judge: No accepted:6submit:7 题目描述: 给定两个数m,n,其中m是一个素数. 将n(0& ...