Tim Liberty
Tim Liberty

Reputation: 2129

Angular 2 date pipe

I am using this code:

{{today | date:'General.dateFormat | translate'}}

where General.dateFormat is a format MM.dd.yyyy stored in my language JSON file. But it is printed as 5 22, 2017 AenerPMl.22PMteFor35PMt | trPMn24lPMte

I think there is an issue with multiple pipe. If I replace General.dateFormat | translate with MM.dd.yyyy it works as it should. How do I give the format from my language json file using the translate pipe?

Upvotes: 5

Views: 408

Answers (1)

Shahid Ahmad
Shahid Ahmad

Reputation: 774

You passed translate pipe as a value to date filters. pass value directly instead of passing General.dateFormat as a string. please try the below code

{{today | date: translate:'General.dateFormat'}}

Upvotes: 2

Related Questions