Search code examples
angularjsattributesangular-translate

Set title attribute with condition and using angular translate


I am using title attribute with some condition and my code is

<li title="{{admin ? 'purchase license pack':''}}"><span translate>pack.details</span></li>

Here when the admin is true then it shows purchase license pack. But how to make that one to i18n keys by using translate filter. I tried this,

<li title="{{admin ? '{{'purchase.pack'|translate}}':''}}"><span translate>pack.details</span></li>

But It shows parsing error. How to do this?


Solution

  • The error was natural since you were trying to interpolate the interpolation. However, You were quite close.. Try This :

    <li title="{{admin ? ('purchase.pack'|translate) : ''}}"><span translate>pack.details</span></li>