DeathNote DeathNote - 4 months ago 31
AngularJS Question

ngTable not working, simple example - copied from official website

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});

Answer

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/