AngularJS: bo-bind of bindonce and the translate filter

1.7k Views Asked by At

I'm using angular 1.2.25, angular-translate 2.0.1, angular-translate-loader-static-files 2.0.0 and angular-bindonce 0.3.1.

What I want to do is translating a static translation key with bindonce. So I got this code snippet:

<div bindonce>
  <div bo-bind="'TEST' | translate"></div>
</div>

As result of this snippet the translation key is displayed instead of the translation. If I'm using now ng-bind instead of bo-bind everything works just fine:

<div>
  <div ng-bind="'TEST' | translate"></div>
</div>

I have stepped through with the debugger and it seems like the translate filter doesn't exist when bo-bind is executed.

Is there any way I can use this one time binding in combination with angular-translate?

Here is a plunker replicating my issue

1

There are 1 best solutions below

0
On

Try:

<div bindonce="languages">  <div bo-bind="'TEST' | translate"></div></div>

in controller just set scope "language" = true when angular-translate build complete. I think you should use rootscope for saving "language"