1

I'm using AngularJS Datatables plugin and I want to sort the table by column. The problem is when I click on a thead cell, everything will disappear. I'll attach some code down below. I tried to look for topics on the same subject, but I couldn't find anything that would help me. What am I doing wrong?

<table datatable="" dt-options="vm.dtOptions" dt-column-defs="vm.dtColumnDefs" class="row-border hover">
            <thead>
            <tr>
                <th>ID</th>
                <th>Username</th>
                <th>Created at</th>
                <th>Role</th>
                <th>Actions</th>
            </tr>
            </thead>
            <tbody>
            <tr ng-repeat="user in users">
                <td>{{user.id}}</td>
                <td>{{user.username}}</td>
                <td>{{user.created_at}}</td>
                <td>{{user.role}}</td>
                <td>
                    <i class="fa fa-2x fa-user" data-toggle="modal" data-target="#user-info" ng-click="vm.getUserById(user.id)"></i>
                    <i class="fa fa-2x fa-edit" data-toggle="modal" data-target="#user-edit"></i>
                    <i class="fa fa-2x fa-trash" data-toggle="modal" data-target="#user-delete"></i>
                </td>
            </tr>
            </tbody>
</table>

Controller

app.controller('UsersController', function UsersController($scope, UserService, DTOptionsBuilder, DTColumnDefBuilder) {

    var vm = this;
    vm.getUserById = getUserById;
    vm.dtOptions = DTOptionsBuilder;
    vm.dtColumnDefs = DTColumnDefBuilder;

   });

1 Answer 1

1

It should be datatable="ng" instead of datatable="" when using angular-datatables the "angular" way.

angular-datatables the "angular" way doc: http://l-lin.github.io/angular-datatables/archives/#!/angularWay

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.