Angular-translate directive inside translation

I am using angular-translate for i18n and want to use the directive inside the translation:

var translations = {
  TEST_1: 'Hello from <a href="/test">Test</a>',
  TEST_2: 'Hello from <user></user>'
};

app.directive('user', function() {
  return {
    template: '<a href="/test">Test</a>'
  };
});

      

Full plnkr example: http://plnkr.co/edit/jCCcvx7IEaAYUwyaQ7uH?p=preview

So

<p translate="TEST_1"></p>
<p translate="TEST_2"></p>

      

should be the same. The first (without directive) works, the second doesn't. It translates <user></user>

, but Angular doesn't seem to be aware of it and does its directive magic.

+3


source to share


1 answer


Try using the directive translate-compile

:

<p translate="TEST_2" translate-compile></p>

      



From the docs :

Since version 2, the translation itself can be submitted after being processed in the context of the current scope (using $ compilation). This means that any directive used in the translation cost itself will now work as expected.

+6


source







All Articles