Pipe to format date with async format retrival. E.g. this can be helpful when using ng2-translate
Date is formated with moment.js
import { DateAsyncFormatModule } from "date-async-format-pipe";
@NgModule({
imports: [
DateAsyncFormatModule
]
})
export class SomeModule {
}
date | dateFormatAsync : format
-
date
: any valid date input for moment.js. -
format
:Observable<string>
that resolves with valid moment.js format patterns.
@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")
}
}