Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use a filter inside translate-values attribute of angular translate

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?

like image 701
CodingBee Avatar asked Mar 22 '16 18:03

CodingBee


1 Answers

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>
like image 122
Brian Medendorp Avatar answered Sep 19 '22 03:09

Brian Medendorp