Matteo Scandolo | 44b7d6b | 2016-12-08 13:48:01 -0800 | [diff] [blame^] | 1 | import { Observable } from 'rxjs/Rx'; |
| 2 | /// <reference path="../../../../typings/index.d.ts"/> |
| 3 | import { IXosTableConfig } from './../../interfaces/xos-components/table.interface'; |
| 4 | import {Component, OnInit, Input} from '@angular/core'; |
| 5 | |
| 6 | @Component({ |
| 7 | selector: 'xos-table', |
| 8 | template: require('./table.component.html'), |
| 9 | }) |
| 10 | export class XosTableComponent implements OnInit { |
| 11 | |
| 12 | public _config; |
| 13 | public _data; |
| 14 | |
| 15 | @Input() config: IXosTableConfig; |
| 16 | @Input() data: Observable<any>; |
| 17 | |
| 18 | |
| 19 | ngOnInit() { |
| 20 | |
| 21 | if (!this.config) { |
| 22 | throw new Error('[XosTable]: You must pass a configuration'); |
| 23 | } |
| 24 | |
| 25 | this._config = this.config; |
| 26 | this.data.subscribe( |
| 27 | (items: any[]) => { |
| 28 | this._data = items; |
| 29 | } |
| 30 | ); |
| 31 | } |
| 32 | } |
| 33 | |