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 | |
| 12 | angular.module('xos.uiComponents.table', []) |
| 13 | .directive('xosTable', function(){ |
| 14 | return { |
| 15 | restrict: 'E', |
| 16 | scope: { |
| 17 | data: '=', |
| 18 | columns: '=' |
| 19 | }, |
Matteo Scandolo | 775d324 | 2016-03-24 16:12:18 -0700 | [diff] [blame] | 20 | 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 Scandolo | 91fe03d | 2016-03-24 15:29:52 -0700 | [diff] [blame] | 35 | bindToController: true, |
| 36 | controllerAs: 'vm', |
| 37 | controller: function(){ |
| 38 | console.log(this.data, this.columns); |
| 39 | } |
| 40 | } |
| 41 | }) |
| 42 | })(); |