chain of angular filters: translation does not refresh

时间:2015-10-06 08:50:17

标签: javascript angularjs angular-translate

In my page code I have expression:

{{key | containerkeyname | translate }}

where key is some string (a field ID), containerkeyname filter takes it and outputs translation key (serving human-friendly description for the field), and finally translate is translating that key.

This works fine initially (translation is provided), however, when I change translation language, this expression is not re-translated (unlike the rest of the interface that uses a lot of translations, mainly made via directive). I am confused, since translation filter is last in line.

What could be the reason and how I could achieve normal re-translation of this expression?

1 个答案:

答案 0 :(得分:0)

AS @Chandermani告诉记者,根本原因可能是$ translate的无状态过滤器。 (请参阅有状态/无状态过滤器的强大功能:http://blog.thoughtram.io/angularjs/2014/11/19/exploring-angular-1.3-stateful-filters.html)因此,仅更改过滤器之前的内容将触发反应。

为了使其有效,我按如下方式更改了代码:

 span(translate='{{key|containerkeyname}}')