import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
+import { RouterModule } from '@angular/router';
import { NgxDatatableModule } from '@swimlane/ngx-datatable';
NgxDatatableModule,
FormsModule,
PipesModule,
- ComponentsModule
+ ComponentsModule,
+ RouterModule
],
declarations: [
TableComponent,
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FormsModule } from '@angular/forms';
+import { RouterTestingModule } from '@angular/router/testing';
import { NgxDatatableModule } from '@swimlane/ngx-datatable';
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ TableComponent, TableKeyValueComponent ],
- imports: [ FormsModule, NgxDatatableModule, ComponentsModule ]
+ imports: [ FormsModule, NgxDatatableModule, ComponentsModule, RouterTestingModule ]
})
.compileComponents();
}));
let-value="value">
<cd-sparkline [data]="value"></cd-sparkline>
</ng-template>
+
+<ng-template #routerLinkTpl
+ let-row="row"
+ let-value="value">
+ <a [routerLink]="[row.cdLink]">{{ value }}</a>
+</ng-template>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FormsModule } from '@angular/forms';
+import { RouterTestingModule } from '@angular/router/testing';
import { NgxDatatableModule, TableColumn } from '@swimlane/ngx-datatable';
async(() => {
TestBed.configureTestingModule({
declarations: [TableComponent],
- imports: [NgxDatatableModule, FormsModule, ComponentsModule]
+ imports: [NgxDatatableModule, FormsModule, ComponentsModule, RouterTestingModule]
}).compileComponents();
})
);
@ViewChild(TableDetailsDirective) detailTemplate: TableDetailsDirective;
@ViewChild('tableCellBoldTpl') tableCellBoldTpl: TemplateRef<any>;
@ViewChild('sparklineTpl') sparklineTpl: TemplateRef<any>;
+ @ViewChild('routerLinkTpl') routerLinkTpl: TemplateRef<any>;
// This is the array with the items to be shown.
@Input() data: any[];
_addTemplates () {
this.cellTemplates.bold = this.tableCellBoldTpl;
this.cellTemplates.sparkline = this.sparklineTpl;
+ this.cellTemplates.routerLink = this.routerLinkTpl;
}
ngOnChanges(changes) {
export enum CellTemplate {
bold = 'bold',
- sparkline = 'sparkline'
+ sparkline = 'sparkline',
+ routerLink = 'routerLink'
}