Matteo Scandolo | 91fe03d | 2016-03-24 15:29:52 -0700 | [diff] [blame] | 1 | /** |
| 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 Scandolo | b7a86dc | 2016-04-14 11:46:30 -0700 | [diff] [blame^] | 12 | |
Matteo Scandolo | 91fe03d | 2016-03-24 15:29:52 -0700 | [diff] [blame] | 13 | angular.module('xos.uiComponents.table', []) |
| 14 | .directive('xosTable', function(){ |
| 15 | return { |
| 16 | restrict: 'E', |
| 17 | scope: { |
| 18 | data: '=', |
| 19 | columns: '=' |
| 20 | }, |
Matteo Scandolo | b7a86dc | 2016-04-14 11:46:30 -0700 | [diff] [blame^] | 21 | 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 Scandolo | 91fe03d | 2016-03-24 15:29:52 -0700 | [diff] [blame] | 36 | bindToController: true, |
| 37 | controllerAs: 'vm', |
| 38 | controller: function(){ |
| 39 | console.log(this.data, this.columns); |
Matteo Scandolo | b7a86dc | 2016-04-14 11:46:30 -0700 | [diff] [blame^] | 40 | console.log('Bella dello zio, RELOAD'); |
Matteo Scandolo | 91fe03d | 2016-03-24 15:29:52 -0700 | [diff] [blame] | 41 | } |
| 42 | } |
| 43 | }) |
| 44 | })(); |