我可以看到表格,但那里没有值 继承人是我的Plunker:http://embed.plnkr.co/RKiEZkxTCJSYpmhR69cI/
我试了好几个小时,无法找到办法做到这一点...... 另外我设置mySQL只显示~800.000的3个结果,如果我删除限制,这将是一个问题吗? 无论如何我想分页。
HTML
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://unpkg.com/ng-table@4.0.0/bundles/ng-table.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
</head>
<body ng-app="myApp" ng-controller="myController as MC">
<table ng-table="MC.tableParams" show-filter="true" class="table table-condensed table-bordered table-striped">
<tr ng-repeat="x in $data">
<td data-title="'Held'" sortable="'Held'">{{ x.Held }}</td>
<td data-title="'Waffe'" sortable="'Waffe'">{{ x.Waffe }}</td>
<td data-title="'Schild'" sortable="'Schild'">{{ x.Schild }}</td>
<td data-title="'Ring'" sortable="'Ring'">{{ x.Ring }}</td>
<td data-title="'Amulett'" sortable="'Amulett'">{{ x.Amulett }}</td>
<td data-title="'Mantel'" sortable="'Mantel'">{{ x.Mantel }}</td>
<td data-title="'ID'" sortable="'ID'">{{ x.ID }}</td>
</tr>
</table>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular.js"></script>
<script src="https://unpkg.com/ng-table@4.0.0/bundles/ng-table.min.js"></script>
<script src="script.js"></script>
</body>
</html>
APP
var test = angular.module('myApp', ['ngTable']);
test.controller('myController', function myController($scope, $http, NgTableParams) {
$scope.tableParams = new NgTableParams({
page: 1, // show first page
count: 5 // count per page
}, {
getData: function($defer, params) {
$http.get('http://sanctuments.16mb.com/getData.php').
$promise.then(function(data, status) {
var orderedData = data;
$defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
})
}
})
});
答案 0 :(得分:2)
最后做到了:
var test = angular.module('myApp', ['ngTable']);
test.controller('myController', function myController($scope, $http, NgTableParams) {
var self = this;
$http.get('http://sanctuments.16mb.com/getData.php').
success(function(data, status) {
self.tableParams = new NgTableParams({}, {
dataset: data
});
});
});
或者更好的这个:
var test = angular.module('myApp', ['ngTable']);
test.controller('myController', ['$scope', '$http', 'NgTableParams',
function myController($scope, $http, NgTableParams) {
var self = this;
$http.get('http://sanctuments.16mb.com/getData.php').success(function(data, status) {
self.tableParams = new NgTableParams({
page: 1, // show first page
count: 10 // count per page
}, {
total: data.length,
getData: function(params) {
return data.slice((params.page() - 1) * params.count(), params.page() * params.count());
}
});
});
}
]);