简体   繁体   English

AngularJS:绑定和绑定过滤器的bo-bind

[英]AngularJS: bo-bind of bindonce and the translate filter

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 . 我正在使用angular 1.2.25angular-translate 2.0.1angular-translate-loader-static-files 2.0.0angular-bindonce 0.3.1

What I want to do is translating a static translation key with bindonce. 我想要做的是使用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: 如果我现在使用ng-bind而不是bo-bind一切都很好:

<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. 我已经调试过调试器,执行bo-bind时似乎不存在翻译过滤器。

Is there any way I can use this one time binding in combination with angular-translate? 有什么方法可以结合角度转换使用一次绑定吗?

Here is a plunker replicating my issue 这是复制我的问题的朋克

Try: 尝试:

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

in controller just set scope "language" = true when angular-translate build complete. 在控制器中,只需在完成angular-translate构建时将范围设置为“ language” = true。 I think you should use rootscope for saving "language" 我认为您应该使用rootscope保存“语言”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM