8

I'm working on an AngularJS application with Angular-Translate 2.6.1. I have a span with a title attribute that will be translated, but it needs to display a variable as well.

<span title={{'translationID'|translate:'{username:"Value"}'}}>...</span>

I've tried replacing "Value" with {{Value}}, with and without quotes. Value is defined in the scope, and I can access it with {{Value}} outside of a filter.

The only luck I've had so far with variable replacement in Angular-Translate is using the translate directive

(e.g. <span translate="translationID" translate-value-username="{{Value}}">...</span>),

but that doesn't seem to be an option here. Is variable replacement in a filter like this possible, or do I need to find another solution?

EDIT: For readability, here is the solution:

<span title="{{'translationID'|translate:{username:Value} }}">...</span>
Tirenoth
  • 83
  • 1
  • 6

1 Answers1

10

The following should work:

<span title="{{'translationID'|translate:{username:Value} }}">...</span>
miensol
  • 39,733
  • 7
  • 116
  • 112
  • Thanks! FYI, that syntax works outside of a tag, but it needs double-quotes around it for it to work as a title. – Tirenoth Apr 29 '15 at 21:25
  • Hello miensol, i also facing some translation problem my heading are bellow . at a time when i will switch language rest of all translation id throw translating. but not this line but its working but when i refresh my page. – KAUSHAL J. SATHWARA Aug 02 '16 at 11:39