File

src/lib/ngx-calendar-table.component.ts

Implements

OnInit

Metadata

host {
}
selector ngx-calendar-table
styleUrls ngx-calendar-table.style.scss
templateUrl ./ngx-calendar-table.component.html

Index

Properties
Methods
Inputs

Constructor

constructor(tableService: NgxCalendarTableService, dateService: DateService)
Parameters :
Name Type Optional
tableService NgxCalendarTableService no
dateService DateService no

Inputs

config

Type: Config

controls

Type: Object

Default value: { previous: 'previous', next: 'next' }

date

Type: Date

Default value: new Date()

rows

Type: any[]

Methods

ngOnInit
ngOnInit()
Returns : void
Private populateColumns
populateColumns()

Build and populate columns

Returns : void
Public receivedDataColumns
receivedDataColumns(data: )

Receive data columns by event emitter

Parameters :
Name Optional
data no
Returns : void

Properties

Public columns
columns: Column[]
Type : Column[]
Public tableContentDirective
tableContentDirective:
Decorators : ContentChild
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>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""