angular服务——$http
来源:互联网 发布:2016赛季林书豪数据 编辑:程序博客网 时间:2024/06/05 21:55
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>$http</title>
<script type="text/javascript" src="js/angular.min.js" ></script>
<script>
var app=angular.module("myApp",[]);
app.controller("myCtrl",function($scope,$http){
$http({
method:"get",//请求路径
url:"myJson.json"//请求的json串 自己写的json串
}).then(function zhengque(response){
//请求正确
$scope.student=response.data;
},function cuowu(){
//请求错误
alert("错误");
});
});
</script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<ul>
<li ng-repeat="s in student">姓名:{{s.name}}</li>
</ul>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title>$http</title>
<script type="text/javascript" src="js/angular.min.js" ></script>
<script>
var app=angular.module("myApp",[]);
app.controller("myCtrl",function($scope,$http){
$http({
method:"get",//请求路径
url:"myJson.json"//请求的json串 自己写的json串
}).then(function zhengque(response){
//请求正确
$scope.student=response.data;
},function cuowu(){
//请求错误
alert("错误");
});
});
</script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<ul>
<li ng-repeat="s in student">姓名:{{s.name}}</li>
</ul>
</body>
</html>
阅读全文
0 0
- angular服务——$http
- Angular核心服务$http
- angular的$http服务
- angular服务——$interval
- angular服务——$myFactory
- angular服务——$myService
- angular的http服务的常用方式
- Angular(四)内置服务$http
- angular中的$http服务(service)解析
- angular服务插件1——对话框&提示框
- angular——内置服务获取本机的信息
- angular.js基础—服务(service)及其调用
- angular服务
- angular-服务
- Angular服务
- angular 服务
- angular服务
- Angular服务
- Git 对比不同commit下的同一文件内容的差别
- 单例模式的实现方法及其优缺点
- Linux Shell中各种分号和括号的用法总结
- linux安装showdoc——让你避过大坑
- 如何将现有的/home目迁移新的单独分区上,或者其它目录迁移到别的分区
- angular服务——$http
- 随想
- spring-mybatis整合xml配置
- map
- Java初窥:JDK1.8中的日期处理
- 深度解析京东个性化推荐系统演进史
- 函数模版与类模版template
- java中进行字符串替换.replace() .indexOf() .lastIndexOf() .substring()
- SpringBoot集成Swagger2