Search code examples
angularangular-directiveng2-translateangular-pipe

ng2-translate directive not working while pipe is


Ng2-translate directive is causing me some issues, but I don't get if I'm doing something wrong or if it's a bug.

On the same component's html template, the translate pipe is working, while the translate directive is not.

In particular:

<span translate>{{ feature.linkTxt }}</span> // works

<span [translate]="feature.linkTxt"></span> // not working

see https://github.com/ocombe/ng2-translate#4-use-the-service-the-pipe-or-the-directive

Am I missing something or should it work?

EDIT

The variable feature.linkTxt points to the string LEARNMORE, which corresponds to the following json string:

"LEARNMORE": "Learn more",

If I switch from the directive to the pipe, with the same variable, the translated text is displayed.

The feature.linkTxt variable is generated by the following *ngFor statement:

<li *ngFor="let feature of featureslist"> ...

Solution

  • It turns out that this is a known open bug.

    See https://github.com/ocombe/ng2-translate/issues/355