获得json数据(表格)
来源:互联网 发布:如何在淘宝上买发票啊 编辑:程序博客网 时间:2024/06/05 20:32
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/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){
var con = confirm("确定删除?");
if(con==true){
$scope.users.splice(index,1);
}
}
$scope.isShow = function(){
if($scope.users.length>0){
return true;
}else{
return false;
}
}
});
/* 1.$http服务请求服务器,获得服务器端的数据 */
</script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<center>
<h3>我的用户表</h3>
<table ng-if="isShow()" border="1px solide blue" cellpadding="10" cellspacing="0" width="600px" align="center">
<thead>
<tr>
<th>用户名</th>
<th>年龄</th>
<th>性别</th>
<th>操作</th>
</tr>
</thead>
<tbody align="center">
<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>
<p ng-if="!isShow()">用户表为空!</p>
</center>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/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){
var con = confirm("确定删除?");
if(con==true){
$scope.users.splice(index,1);
}
}
$scope.isShow = function(){
if($scope.users.length>0){
return true;
}else{
return false;
}
}
});
/* 1.$http服务请求服务器,获得服务器端的数据 */
</script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<center>
<h3>我的用户表</h3>
<table ng-if="isShow()" border="1px solide blue" cellpadding="10" cellspacing="0" width="600px" align="center">
<thead>
<tr>
<th>用户名</th>
<th>年龄</th>
<th>性别</th>
<th>操作</th>
</tr>
</thead>
<tbody align="center">
<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>
<p ng-if="!isShow()">用户表为空!</p>
</center>
</body>
</html>
阅读全文
0 0
- 获得json数据(表格)
- json数据表格
- 获得json数据
- json 读取数据创建表格
- json 填充表格数据 转置
- JSON数据转成html表格
- jquery_ajax get()获得json数据
- jquery 根据表格行ID 获得数据
- EXTJs 实现表格数据显示-----JSON
- jQuery表格插件jqGrid之JSON数据
- js将表格数据转换成json
- json数据 填充遍历表格行列 jQuery
- Strust2 + JSON + jquery 分页表格显示数据
- Json 批量表格/表单数据的处理
- JQuery绑定JSON数据至表格插件
- bootstrap 遍历json数据添加表格内容
- EXCEL表格转换成json数据工具
- js通过变量获得json数据
- Unable to locate package错误解决办法
- type=image 来提交表单和type=submit提交表单的不同
- javabean属性复制BeanUtil
- 配置NDK,使用JNI
- oracle start with connect by prior 递归查询用法
- 获得json数据(表格)
- python和mysql交互
- Android 购物车相关(全选/反选、删除、网络数据)
- 使用MapStruct处理javabean之间的转换
- MYSQL性能优化
- 美研发可为手机充电面料 Model3试驾曝出大量问题
- 安装 DockerToolBox
- LCD IP KVM使用经典案例
- 爬虫网易LOFTER图片(适用于类似网页,如百度贴吧 )