分页对吴-表加载JSON数据后不工作 [英] Pagination not working after loading JSON data on Ng-Table

查看:190
本文介绍了分页对吴-表加载JSON数据后不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我也跟着在 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.

这篇关于分页对吴-表加载JSON数据后不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆