Started table component
diff --git a/views/ngXosLib/xosHelpers/src/ui_components/table/table.component.js b/views/ngXosLib/xosHelpers/src/ui_components/table/table.component.js
index 692b49d..0a81475 100644
--- a/views/ngXosLib/xosHelpers/src/ui_components/table/table.component.js
+++ b/views/ngXosLib/xosHelpers/src/ui_components/table/table.component.js
@@ -16,19 +16,19 @@
restrict: 'E',
scope: {
data: '=',
- columns: '='
+ config: '='
},
template: `
- <!--<pre>{{vm.data | json}}</pre>-->
- <table class="table table-striped" ng-show="vm.data.length > 0">
+ <!-- <pre>{{vm.data | json}}</pre> -->
+ <table ng-class="vm.classes" ng-show="vm.data.length > 0">
<thead>
<tr>
- <th ng-repeat="col in vm.columns">{{col}}</th>
+ <th ng-repeat="col in vm.columns">{{col.label}}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in vm.data">
- <td ng-repeat="col in vm.columns">{{item[col]}}</td>
+ <td ng-repeat="col in vm.columns">{{item[col.prop]}}</td>
</tr>
</tbody>
</table>
@@ -36,7 +36,18 @@
bindToController: true,
controllerAs: 'vm',
controller: function(){
- console.log(this.data, this.columns);
+
+ if(!this.config){
+ throw new Error('[xosTable] Please provide a configuration via the "config" attribute');
+ }
+
+ if(!this.config.columns){
+ throw new Error('[xosTable] Please provide a columns list in the configuration');
+ }
+
+ this.columns = this.config.columns;
+ this.classes = this.config.classes || 'table table-striped table-bordered';
+
console.log('Bella dello zio, RELOAD');
}
}