<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="../kuwenjian/angular.js" ></script>
<script>
var app = angular.module("myapp" , []);
app.controller("mycon" , function($scope,$http){
$http({
method:"get",
url:"hoo.json"
}).then(function success(response){
$scope.users = response.data;
}),function error(){
$scope.users = null;
}
//删除用户
$scope.delete = function(index){
$scope.users.splice(index,1);
}
});
</script>
</head>
<body ng-app="myapp" ng-controller="mycon">
<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>
</html>
anjularjs遍历json文件
最新推荐文章于 2018-06-18 23:39:06 发布