我也跟着在 http://bazalt-cms.com/为分页,但使用 $ http.get
而不是硬编码在控制器的一个变量。
I followed the example on http://bazalt-cms.com/ for the pagination but using $http.get
instead of hard-coding a variable in the controller.
$http.get("data.json").success(function(data){
$scope.dataset = data;
}
我也感动了 $ scope.tableParams
中的 $ http.get
$http.get("data.json").success(function(data){
$scope.dataset = data;
$scope.tableParams = new ngTableParams({
...
}
});
和改变了数据
变量 $ scope.dataset
total: $scope.dataset.length, // length of data
getData: function($defer, params) {
$defer.resolve($scope.dataset.slice((params.page() - 1) * params.count(), params.page() * params.count()));}
一切工作正常,除了分页现在不工作这里见Plnkr
我一直在 NG-表
工作了一段时间。当我试图用比 $数据等变量名
或数据
,它似乎并没有工作。因此,我建议你应该坚持使用 $数据
或数据
而不是任何其他变量的名称,如数据集
。
I've been working with ng-table
for a while. When I tried using variable names other than $data
or data
, it doesn't seem to work. So I suggest you should stick to using $data
or data
instead of any other variable names like dataset
.
下面是一个工作 Plunker 。
Here's a working Plunker.
更新
看起来像我错过了,看看是什么在OP的问题真的错了。由于的泰勒科利尔的和的尤纳斯黑热病的在评论中提到的,你只需要使用 $数据
如< TR NG重复=用户在$数据>
而不是< TR NG重复=用户数据>
。而且,如果你在你的控制器code使用数据
或集
没关系。
Looks like I missed to see what was really wrong in the OP's question. As Tyler Collier and yunus kala mentioned in the comments, you just have to use $data
like <tr ng-repeat="user in $data">
instead of <tr ng-repeat="user in dataset">
. And it doesn't matter if you use data
or dataset
in your controller code.