print tables with dynamic columns angularjs and ngtable -


i'm using angularjs , ngtable , wish print table dynamically generated.

this code:

var app = angular.module('dl', ['ngtable']);    app.controller('dactrl', function($scope, ngtableparams, $http)   {       $scope.headers=[];     $scope.data = [];          //----------------------example--------------------------    //---$scope.header[{label: "value1"},{label: "value2"},{label: "value3"}]-----    //---$scope.data[{value1: 1, value2: 2, value3: 3},{value1: 18, value2: 30, value3: 6}, {value1: 15, value2: 21, value3: 56},......]--------------    //------- header y data are dynamically generated                        $scope.tableparams = new ngtableparams({                          page: 1,                          count: 10,                          filter: {                              message: ''                          },                          sorting: {                              asset: 'asc'                          }                      },                      {                          total: $scope.data.length,                          counts:[],                          getdata: function($defer, params) {                              var ordereddata = params.sorting() ?                                  $filter('orderby')($scope.data, params.orderby()) :                                  $scope.data;                                params.total(ordereddata.length);                              $defer.resolve(ordereddata.slice((params.page() - 1) * params.count(), params.page() * params.count()));                          }                        });                  });          });               });
<div ng-app="dl" ng-controller="dactrl">      <table ng-table="tableparams" class="table table-striped table-hover table-bordered">    <tr ng-repeat="a in $data | filter:search" style="text-align:center;">    <td ng-repeat="col in headers" data-title="'{{col.label}}'" sortable="'tg1'">{{a.[col.label]}}</td>                           </tr>                  </table>    </div>    <!-- how write {{a.[col.label]}}

my main problem in html view , print structure. when table known columns have no problems.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -