angularjs - Angular ng-table sorting not working in fixed header -


i new angularjs. have created table using ng-table, problem table header sorting not working.

sample code attached here.

html : (sample ng-table)

<table ng-table="tableparams" show-filter="true" class="table">     <thead>         <tr>row 1</tr>         <tr>row 2</tr>         <tr>row 3</tr>         <tr>row 4</tr>         <tr>row 5</tr>         <tr>row 6</tr>     </thead>     <tbody>         <tr ng-repeat="user in $data">             <td sortable="'value1'">{{user.value1}}</td>             <td sortable="'value2'">{{user.value2}}</td>             <td sortable="'value3'">{{user.value3}}</td>             <td sortable="'value4'">{{user.value4}}</td>             <td sortable="'value5'">{{user.value5}}</td>             <td sortable="'value6'">{{user.value6}}</td>         </tr>     </tbody> </table> 

controller :

    $http.get('/portal/api/documents/'+id).success(function(data){             var data = data.result;             $scope.tableparams = new ngtableparams({                 page: 1,            // show first page                 count: 10,           // count per page                 sorting: {                     name: 'asc'     // initial sorting                 }             }, {                 total: data.length, // length of data                 getdata: function($defer, params) {                   // pagination                   $defer.resolve(data.slice((params.page() - 1) * params.count(), params.page() * params.count()));                    // use build-in angular filter                     var ordereddata = params.sorting ?                             $filter('orderby')(data, params.orderby()) :                             data;                      $defer.resolve(ordereddata.slice((params.page() - 1) * params.count(), params.page() * params.count()));                 }             });     }); 

i think problem comes sorting configuration :

sorting: {    name: 'asc'     // initial sorting } 

you seem not have name parameter in 1 of table column (value1, value2, ... unless didn't show real code)

if want sort first column, should try :

sorting: {    value1: 'asc'     // initial sorting } 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -