<html ng-app="myApp">
<head>
<meta charset="utf-8" />
<title>获取网络</title>
<script type="text/javascript" src="libs/angular.min.js"></script>
<script>
var App = angular.module("myApp", []);
App.controller("Democtrl", function($scope, $http) {
$http({
method: "GET",
// 获取本地 json 字符串
url: "package.json"
// 正确的
}).success(function(data) {
// 看清楚是否获取的是否是 数组 还是 对象
// $scope.datas = data.records;
$scope.datas = data;
console.log($scope.datas);
// 错误的
}).error(function(data) {
})
});
</script>
</head>
<body ng-controller="Democtrl">
<center>
<table border="1">
<thead>
<tr style="background-color: yellow;">
<td><input type="checkbox" ng-model="selectAll" ng-click="selectAllFun()" /></td>
<td width="100px">aid</td>
<td width="100px">atitle</td>
<td width="230px">操作</td>
</tr>
</thead>
<tbody>
<tr ng-repeat="a in datas">
<td><input type="checkbox" ng-model="a.state" /></td>
<td>{{a.id}}</td>
<td>{{a.title}}</td>
<!--删除-->
<td>
<button ng-click="del(a.id)">删除</button>
</td>
</tr>
</tbody>
</table>
</center>
</body>
</html>
<head>
<meta charset="utf-8" />
<title>获取网络</title>
<script type="text/javascript" src="libs/angular.min.js"></script>
<script>
var App = angular.module("myApp", []);
App.controller("Democtrl", function($scope, $http) {
$http({
method: "GET",
// 获取本地 json 字符串
url: "package.json"
// 正确的
}).success(function(data) {
// 看清楚是否获取的是否是 数组 还是 对象
// $scope.datas = data.records;
$scope.datas = data;
console.log($scope.datas);
// 错误的
}).error(function(data) {
})
});
</script>
</head>
<body ng-controller="Democtrl">
<center>
<table border="1">
<thead>
<tr style="background-color: yellow;">
<td><input type="checkbox" ng-model="selectAll" ng-click="selectAllFun()" /></td>
<td width="100px">aid</td>
<td width="100px">atitle</td>
<td width="230px">操作</td>
</tr>
</thead>
<tbody>
<tr ng-repeat="a in datas">
<td><input type="checkbox" ng-model="a.state" /></td>
<td>{{a.id}}</td>
<td>{{a.title}}</td>
<!--删除-->
<td>
<button ng-click="del(a.id)">删除</button>
</td>
</tr>
</tbody>
</table>
</center>
</body>
</html>