src/lib/ngx-calendar-table.component.ts
host | { |
selector | ngx-calendar-table |
styleUrls | ngx-calendar-table.style.scss |
templateUrl | ./ngx-calendar-table.component.html |
Properties |
|
Methods |
|
Inputs |
constructor(tableService: NgxCalendarTableService, dateService: DateService)
|
|||||||||
Defined in src/lib/ngx-calendar-table.component.ts:26
|
|||||||||
Parameters :
|
config
|
Type: |
Defined in src/lib/ngx-calendar-table.component.ts:21
|
controls
|
Type:
Default value: |
Defined in src/lib/ngx-calendar-table.component.ts:22
|
date
|
Type:
Default value: |
Defined in src/lib/ngx-calendar-table.component.ts:20
|
rows
|
Type: |
Defined in src/lib/ngx-calendar-table.component.ts:19
|
ngOnInit |
ngOnInit()
|
Defined in src/lib/ngx-calendar-table.component.ts:33
|
Returns :
void
|
Private populateColumns |
populateColumns()
|
Defined in src/lib/ngx-calendar-table.component.ts:45
|
Build and populate columns
Returns :
void
|
Public receivedDataColumns | ||||
receivedDataColumns(data: )
|
||||
Defined in src/lib/ngx-calendar-table.component.ts:58
|
||||
Receive data columns by event emitter
Parameters :
Returns :
void
|
Public columns |
columns:
|
Type : Column[]
|
Defined in src/lib/ngx-calendar-table.component.ts:18
|
Public tableContentDirective |
tableContentDirective:
|
Decorators : ContentChild
|
Defined in src/lib/ngx-calendar-table.component.ts:26
|
import { Component, OnInit, Input, ContentChild, TemplateRef } from '@angular/core';
import { DateService } from '../services/date/date.service';
import { Column } from './models/Column';
import { NgxCalendarTableService } from './ngx-calendar-table.service';
import { NgxCalendarTableContentDirective } from './directives/ngx-calendar-table-content.directive';
import { Config } from './models/Config';
import * as _ from 'lodash';
@Component({
selector: 'ngx-calendar-table',
templateUrl: './ngx-calendar-table.component.html',
styleUrls: ['./ngx-calendar-table.style.scss'],
host: { class: 'ngx-calendar-content-table' }
})
export class NgxCalendarTableComponent implements OnInit
{
public columns: Column[];
@Input() public rows: any[];
@Input() public date: Date = new Date();
@Input() public config: Config;
@Input() public controls: Object = { previous: 'previous', next: 'next' };
@ContentChild(
NgxCalendarTableContentDirective,
{ read: TemplateRef }
) public tableContentDirective;
constructor(
private tableService: NgxCalendarTableService,
private dateService: DateService
) { }
ngOnInit()
{
this.tableService.manipulateRows(
this.rows,
this.config.frequency
);
this.populateColumns();
}
/**
* Build and populate columns
*/
private populateColumns(): void
{
this.columns = this.tableService.buildColumns(
this.date,
this.config.columnsNumber,
this.config.frequency,
this.config.format
);
}
/**
* Receive data columns by event emitter
*/
public receivedDataColumns(data): void
{
this.columns = data;
}
}
<div class="calendar-table-wrapper">
<table class="calendar-table">
<tr>
<th *ngFor="let column of columns">
{{ column.header }}
</th>
</tr>
<tr *ngFor="let row of rows">
<ng-container
[ngTemplateOutlet]="tableContentDirective"
[ngTemplateOutletContext]="{ row: row, columns: columns }">
</ng-container>
</tr>
</table>
<ngx-calendar-table-controls
[columns]="columns"
[labels]="controls"
[config]="config"
(notifierData)="receivedDataColumns($event)">
</ngx-calendar-table-controls>
</div>