11

I am trying to use angular translate to display something like - Posted By John Doe on 1st Jan,2016 - where John Doe and 1st Jan,2016 are dynamic scope variables.

So, I have something like

<p translate="TRANSLATION-STRING" translate-values='{ name: myname, date:mydate }'></p>

and translation string defined as TRANSLATION-STRING: "Posted on {{ name}} by {{date}}"

So far it is fine but what I have is a very long date and so i want to apply a date filter to the translate-value, something like

<p translate="TRANSLATION-STRING" translate-values='{ name: myname, date:mydate|date:'MMM dd , yyyy' }'></p>

This does not seem to work. How can a filter be applied in view and passed to angular translate value?

CodingBee
  • 141
  • 1
  • 1
  • 11

1 Answers1

20

I had the same issue, and it appears that using parenthesis around the individual data elements works. Try this:

<p translate="TRANSLATION-STRING" translate-values='{ name: myname, date: (mydate | date:'MMM dd , yyyy') }'></p>
Brian Medendorp
  • 289
  • 2
  • 5
  • 1
    Also, for ref https://angular-translate.github.io/docs/#/guide/06_variable-replacement – STEEL Sep 19 '16 at 07:24