2016-10-23 22:37:15 +02:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
|
*/
|
|
|
|
|
|
2016-09-02 12:37:22 -07:00
|
|
|
import {Component, Input, NgModule} from '@angular/core';
|
|
|
|
|
import {BrowserModule} from '@angular/platform-browser';
|
|
|
|
|
|
|
|
|
|
import {TableCell, emptyTable} from '../util';
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'largetable',
|
|
|
|
|
template: `<table><tbody>
|
2016-10-12 16:36:18 -07:00
|
|
|
<tr *ngFor="let row of data; trackBy: trackByIndex">
|
2017-01-09 13:16:46 -08:00
|
|
|
<ng-template ngFor [ngForOf]="row" [ngForTrackBy]="trackByIndex" let-cell><ng-container [ngSwitch]="cell.row % 2">
|
2016-10-23 22:37:15 +02:00
|
|
|
<td *ngSwitchCase="0" style="background-color: grey">{{cell.value}}</td><td *ngSwitchDefault>{{cell.value}}</td>
|
2017-01-09 13:16:46 -08:00
|
|
|
</ng-container></ng-template>
|
2016-10-12 16:36:18 -07:00
|
|
|
</tr>
|
|
|
|
|
</tbody></table>`
|
2016-09-02 12:37:22 -07:00
|
|
|
})
|
|
|
|
|
export class TableComponent {
|
|
|
|
|
@Input()
|
|
|
|
|
data: TableCell[][] = emptyTable;
|
2016-10-12 16:36:18 -07:00
|
|
|
|
|
|
|
|
trackByIndex(index: number, item: any) { return index; }
|
2016-09-02 12:37:22 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@NgModule({imports: [BrowserModule], bootstrap: [TableComponent], declarations: [TableComponent]})
|
|
|
|
|
export class AppModule {
|
|
|
|
|
}
|