Http网络请求数据
来源:互联网 发布:电脑软件服务打不开 编辑:程序博客网 时间:2024/06/11 04:58
<title></title>
<script type="text/javascript" src="../../angular/angular.js" ></script>
<script>
var app = angular.module("myApp",[]);
//注入$http对象
app.controller("myCtrl",function($scope,$http){
//调用$http()请求服务器。
$http({
method:"get",//请求方式
url:"haha.json"//请求路径
}).then(function success(response){//请求成功之后的回调函数
//console.log(response.data[1].sex);
$scope.users = response.data;//获取json数据源中的数据
},function error(){//请求失败时执行的回调函数
$scope.users = null;
});
//删除用户
$scope.delete = function(index){
$scope.users.splice(index,1);
}
});
/* 1.$http服务请求服务器,获得服务器端的数据 */
</script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<center>
<h3>我的用户表</h3>
<table border="1px solide blue" cellpadding="10" cellspacing="0">
<thead>
<tr>
<th>用户名</th>
<th>年龄</th>
<th>性别</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="user in users">
<td>{{user.name}}</td>
<td>{{user.age}}</td>
<td>{{user.sex}}</td>
<td><button ng-click="delete($index)">删除</button></td>
</tr>
</tbody>
</table>
</center>
<script type="text/javascript" src="../../angular/angular.js" ></script>
<script>
var app = angular.module("myApp",[]);
//注入$http对象
app.controller("myCtrl",function($scope,$http){
//调用$http()请求服务器。
$http({
method:"get",//请求方式
url:"haha.json"//请求路径
}).then(function success(response){//请求成功之后的回调函数
//console.log(response.data[1].sex);
$scope.users = response.data;//获取json数据源中的数据
},function error(){//请求失败时执行的回调函数
$scope.users = null;
});
//删除用户
$scope.delete = function(index){
$scope.users.splice(index,1);
}
});
/* 1.$http服务请求服务器,获得服务器端的数据 */
</script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<center>
<h3>我的用户表</h3>
<table border="1px solide blue" cellpadding="10" cellspacing="0">
<thead>
<tr>
<th>用户名</th>
<th>年龄</th>
<th>性别</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="user in users">
<td>{{user.name}}</td>
<td>{{user.age}}</td>
<td>{{user.sex}}</td>
<td><button ng-click="delete($index)">删除</button></td>
</tr>
</tbody>
</table>
</center>
</body>
JSON
[{"name":"张三","age":20,"sex":"男"},
{"name":"李四","age":21,"sex":"女"},
{"name":"王五","age":22,"sex":"男"},
{"name":"赵六","age":23,"sex":"女"}]
阅读全文
0 0
- http,请求网络数据
- Http请求网络数据
- Http网络请求数据
- cocos2dx lua http请求获取网络数据:
- cocos2dx lua http请求获取网络数据:
- Android网络框架xUtils的Http网络数据请求操作
- 使用AFinal框架实现HTTP请求从网络获取数据
- Http使用get或post请求网络数据
- Http使用get或post请求网络数据
- http网络请求
- android 网络请求 http
- HTTP网络请求
- HTTP POST 网络请求
- HTTP网络请求
- iOS9 http 网络请求
- Http网络请求
- 网络请求Http
- http网络请求
- nginx外网映射工具连接不上新处理方案
- Ajax之jQuery.serialize()
- 从服务器上下载压缩包
- 多线程编程之八:pthread读写锁
- mysql——windows相关配置
- Http网络请求数据
- 对输入数据进行多个异常处理
- OpenCV-005:图片的基本像素操作
- 获取文件的信息
- java序列化
- STL 二分查找 upper_bound和lower_bound用法
- 关于java数据库章节connection连接不成功的时候!!!
- triplet loss总结
- js简单字母验证码