blob: 692b49df281a3485e8133ab0ec424d9c8acd8b2b [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
Matteo Scandolo1dab3e02016-04-14 11:46:30 -070012
Matteo Scandolo66351432016-03-24 15:29:52 -070013 angular.module('xos.uiComponents.table', [])
14 .directive('xosTable', function(){
15 return {
16 restrict: 'E',
17 scope: {
18 data: '=',
19 columns: '='
20 },
Matteo Scandolo1dab3e02016-04-14 11:46:30 -070021 template: `
22 <!--<pre>{{vm.data | json}}</pre>-->
23 <table class="table table-striped" ng-show="vm.data.length > 0">
24 <thead>
25 <tr>
26 <th ng-repeat="col in vm.columns">{{col}}</th>
27 </tr>
28 </thead>
29 <tbody>
30 <tr ng-repeat="item in vm.data">
31 <td ng-repeat="col in vm.columns">{{item[col]}}</td>
32 </tr>
33 </tbody>
34 </table>
35 `,
Matteo Scandolo66351432016-03-24 15:29:52 -070036 bindToController: true,
37 controllerAs: 'vm',
38 controller: function(){
39 console.log(this.data, this.columns);
Matteo Scandolo1dab3e02016-04-14 11:46:30 -070040 console.log('Bella dello zio, RELOAD');
Matteo Scandolo66351432016-03-24 15:29:52 -070041 }
42 }
43 })
44})();