7
votes

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>
1

1 Answers

9
votes

The following should work:

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