date-async-format-pipe
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

DateAsyncFormatPipe

Pipe to format date with async format retrival. E.g. this can be helpful when using ng2-translate

Date is formated with moment.js

How to use

Module import

import { DateAsyncFormatModule } from "date-async-format-pipe";

@NgModule({
    imports: [
        DateAsyncFormatModule
    ]
})
export class SomeModule {
}

template

date | dateFormatAsync : format

Where

  • date: any valid date input for moment.js.
  • format: Observable<string> that resolves with valid moment.js format patterns.

Example

@Component({
  template: `<div>{{ date | dateFormatAsync : dateFormat$ }}</div> `
})
class SomeComponent {
  public date: Date;
  public dateFormat$: Observable<string>;

  constructor(private translate: TranslateService) {
    this.date = new Date();
    this.dateFormat$ = translate.get("TIME_SHORT")
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i date-async-format-pipe

Weekly Downloads

5

Version

1.2.0

License

Apache-2.0

Last publish

Collaborators

  • fronk