Skip to content

Instantly share code, notes, and snippets.

@bcherny
Created June 21, 2014 01:55
Show Gist options
  • Save bcherny/b5b772c6da2bc0a8f6fb to your computer and use it in GitHub Desktop.
Save bcherny/b5b772c6da2bc0a8f6fb to your computer and use it in GitHub Desktop.

smart-table

<smart-table
   config="globalConfig"
   class="table table-striped"
   columns="usageStatsColumns"
   subheaders="subheaders"
   rows="usageStatsData"
>
</smart-table>

smart-table directive

scope: {
   columnCollection: '=columns',
   subHeaders:'=subheaders'
   dataCollection: '=rows',
   config: '='
}

smart-table table template

<thead>
   <tr class="smart-table-header-row">
      <th ng-repeat="column in columns" ng-include="column.headerTemplateUrl" scope="col" class="smart-table-header-cell {{column.headerClass}}" ng-class="{'sort-ascent':column.reverse==false, 'sort-descent':column.reverse==true}"></th>
   </tr>
   <tr class="smart-table-subheader-row" ng-repeat="subheaderRow in subheaders">
      <th ng-repeat="subheader in subheaderRow" ng-include="column.subheaderTemplateUrl" class="smart-table-subheader-cell {{subheader.className}}" ng-class="{'sort-ascent':column.reverse==false, 'sort-descent':column.reverse==true}"></th>
   </tr>
</thead>

smart-table consumer

$scope.subheaders = [
   [
      {label: 'Foo', className: 'Bar', templateUrl: 'foo.html' },
      {label: ''},
      {className: 'Baz'},
      {label: 'Bar'}
   ]
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment