File

src/pipes/calendarDate.pipe.ts

Description

This pipe is primarily for rendering the current view title. Example usage:

// where `viewDate` is a `Date` and view is `'month' | 'week' | 'day'`
{{ viewDate | calendarDate:(view + 'ViewTitle'):'en' }}

import { Pipe, PipeTransform, LOCALE_ID, Inject } from '@angular/core';
import { CalendarDateFormatter } from './../providers/calendarDateFormatter.provider';

/**
 * This pipe is primarily for rendering the current view title. Example usage:
 * ```
 * // where `viewDate` is a `Date` and view is `'month' | 'week' | 'day'`
 * {{ viewDate | calendarDate:(view + 'ViewTitle'):'en' }}
 * ```
 */
@Pipe({
  name: 'calendarDate'
})
export class CalendarDatePipe implements PipeTransform {

  constructor(private dateFormatter: CalendarDateFormatter, @Inject(LOCALE_ID) private locale: string) {}

  transform(date: Date, method: string, locale: string = this.locale): string {
    return this.dateFormatter[method]({date, locale});
  }

}

results matching ""

    No results matching ""