blob: e384c98e86981b4d46babafab8fd4373af4a1386 [file] [log] [blame]
Matteo Scandolo66351432016-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 Scandoloc443c2d2016-03-24 16:12:18 -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 `,
Matteo Scandolo66351432016-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})();