blob: faeaa26d37721e5174e28d32865f8e094be1651e [file] [log] [blame]
Matteo Scandolo91fe03d2016-03-24 15:29:52 -07001/**
2 * © OpenCORD
3 *
4 * Visit http://guide.xosproject.org/devguide/addview/ for more information
5 *
6 * Created by teone on 3/24/16.
7 */
8
9(function () {
10 'use strict';
11
12 angular.module('xos.uiComponents.table', [])
13 .directive('xosTable', function(){
14 return {
15 restrict: 'E',
16 scope: {
17 data: '=',
18 columns: '='
19 },
Matteo Scandolob7c91cf2016-03-29 14:23:20 -070020 template: [
21 '<!--<pre>{{vm.data | json}}</pre>-->',
22 '<table class="table table-striped" ng-show="vm.data.length > 0">',
23 '<thead>',
24 '<tr>',
25 '<th ng-repeat="col in vm.columns">{{col}}</th>',
26 '</tr>',
27 '</thead>',
28 '<tbody>',
29 '<tr ng-repeat="item in vm.data">',
30 '<td ng-repeat="col in vm.columns">{{item[col]}}</td>',
31 '</tr>',
32 '</tbody>',
33 '</table>'
34 ].join(),
Matteo Scandolo91fe03d2016-03-24 15:29:52 -070035 bindToController: true,
36 controllerAs: 'vm',
37 controller: function(){
38 console.log(this.data, this.columns);
39 }
40 }
41 })
42})();