Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular-Translate Variable Replacement in Title Attribute

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>
like image 273
Tirenoth Avatar asked Apr 29 '15 20:04

Tirenoth


1 Answers

The following should work:

<span title="{{'translationID'|translate:{username:Value} }}">...</span>
like image 115
miensol Avatar answered Oct 19 '22 16:10

miensol