xos-table component with minimal configuration
Change-Id: If1af35fcb30556c5ca34ffeb2b6e2b11fc87ffae
diff --git a/src/app/components/tables/table.component.html b/src/app/components/tables/table.component.html
new file mode 100644
index 0000000..d945ae7
--- /dev/null
+++ b/src/app/components/tables/table.component.html
@@ -0,0 +1,10 @@
+<table>
+ <tr>
+ <th *ngFor="let col of _config.columns">{{col.label}}</th>
+ </tr>
+ <tr *ngFor="let item of _data">
+ <td *ngFor="let col of _config.columns">
+ {{item[col.prop]}}
+ </td>
+ </tr>
+</table>
\ No newline at end of file
diff --git a/src/app/components/tables/table.component.ts b/src/app/components/tables/table.component.ts
new file mode 100644
index 0000000..7e62235
--- /dev/null
+++ b/src/app/components/tables/table.component.ts
@@ -0,0 +1,33 @@
+import { Observable } from 'rxjs/Rx';
+/// <reference path="../../../../typings/index.d.ts"/>
+import { IXosTableConfig } from './../../interfaces/xos-components/table.interface';
+import {Component, OnInit, Input} from '@angular/core';
+
+@Component({
+ selector: 'xos-table',
+ template: require('./table.component.html'),
+})
+export class XosTableComponent implements OnInit {
+
+ public _config;
+ public _data;
+
+ @Input() config: IXosTableConfig;
+ @Input() data: Observable<any>;
+
+
+ ngOnInit() {
+
+ if (!this.config) {
+ throw new Error('[XosTable]: You must pass a configuration');
+ }
+
+ this._config = this.config;
+ this.data.subscribe(
+ (items: any[]) => {
+ this._data = items;
+ }
+ );
+ }
+}
+