2

Website I followed : http://ng-table.com/

I was searching for table directives to quicken the whole work and I landed to ngTable github page and their specific web url.

I followed the process listed on their main page, but I don't know why this isn't working.

js fiddle link : Click Here

HTML

<table ng-table="vm.tableParams" class="table" show-filter="true">
    <tr ng-repeat="user in $data">
        <td title="'Name'" filter="{ name: 'text'}" sortable="'name'">
            {{user.name}}</td>
        <td title="'Age'" filter="{ age: 'number'}" sortable="'age'">
            {{user.age}}</td>
    </tr>
</table>

Controller

var self = this;
var data = [{name: "Moroni", age: 50},{name: "Moroni", age: 50},{name: "Moroni", age: 50},{name: "Moroni", age: 50},{name: "Moroni", age: 50},{name: "Moroni", age: 50}];
self.tableParams = new NgTableParams({}, { dataset: data});
DeathNote
  • 254
  • 1
  • 3
  • 13

1 Answers1

2

I changed some things in your example. Here's the basic stuff in the controller:

$scope.data = [{
  name: "Test1",
  age: 50
}, {
  name: "Test2",
  age: 51
}, {
  name: "Test3",
  age: 52
}, {
  name: "Test4",
  age: 53
}, {
  name: "Test5",
  age: 54
}, {
  name: "Test6",
  age: 55
}];

$scope.tableParams = new NgTableParams({}, {
  dataset: $scope.data
});

Hopefully this will give you a point in the right direction of solving your problem.

Working demo: https://jsfiddle.net/thepio/ushoubbx/

thepio
  • 6,193
  • 5
  • 35
  • 54
  • Thanks man for quick answer, the problem was because of tableparams thingy right? – DeathNote Aug 04 '16 at 12:00
  • No problem and yes that was your problem. Sorry for not being clear in my answer. – thepio Aug 04 '16 at 12:05
  • Hey thepio, one more help needed. Let's say I have 100 json objects in a data chunk now when the 10th page is clicked by the user I'd like to 100 new elements, how will handle that using ngTable. I can solve the backend issue I just want to know how to call for a function etc when last page is reached. – DeathNote Aug 04 '16 at 12:29
  • I think you can find a solution here: http://stackoverflow.com/q/23325994/2003702 or if not you should ask another question :) – thepio Aug 04 '16 at 13:07
  • http://stackoverflow.com/questions/38769681/ngtable-how-to-load-new-data-after-withstanding-data-has-been-seen – DeathNote Aug 04 '16 at 14:07
  • Awesome! I might take a look at it tomorrow if I have time :) – thepio Aug 04 '16 at 17:56