-2

I am implementing angular datatable in my angularjs based application, i am doing rest service call and getting list of objects as a response to angularjs controller like

roomCategories.fetch({}, function(list){
            $scope.categories = list.list;
        });

In this scope i'll get the list of object, i need to set the scope var in angular datatable. But when i try to implement as

$scope.dtOptions = DTOptionsBuilder.fromFnPromise($scope.categories)
    .withPaginationType('full_numbers');
    $scope.dtColumnDefs = [
        DTColumnDefBuilder.newColumnDef(0).withTitle('Name'),
        DTColumnDefBuilder.newColumnDef(1).withTitle('Description')
      ];

I have seen the example like json or array implementation is explained, but i need to add or set the scope var i.e., list in the datatable.

in my html code

<table datatable dt-options="dtOptions" dt-column-defs="dtColumnDefs"></table>

But data is not reflected in page, can anyone help me to solve this issue.

Manoj Kumar
  • 41
  • 1
  • 10
  • 1
    First, you are using DTOptionsBuilder.fromFnPromise but you are not passing promise on it, second, you question is not clear?! – Bettimms Apr 06 '16 at 05:00

1 Answers1

0

i think you can do something like this:

    <div ng-controller="AngularWayCtrl as showCase">
    <table datatable="ng" class="row-border hover">
        <thead>
        <tr>
            <th>ID</th>
            <th>FirstName</th>
            <th>LastName</th>
        </tr>
        </thead>
        <tbody>
        <tr ng-repeat="row in yourData">
            <td>{{row.id}}</td>
            <td>{{row.firstName}}</td>
            <td>{{row.lastName}}</td>
        </tr>
        </tbody>
    </table>
</div>

Hope it helps.

Sparw
  • 2,688
  • 1
  • 15
  • 34
  • yes i have this type of way also but i need have a href link for editing for particular column, since i don't find any option like dat only row select is available like – Manoj Kumar Apr 05 '16 at 16:00