[英]One-time binding with filter
I'll migrate my angularjs application from 1.2.0 to 1.3.0-rc2 and I want to change my code from bindonce to the new one-time binding.IS also used angular-translation. 我将我的angularjs应用程序从1.2.0迁移到1.3.0-rc2,我想将我的代码从bindonce更改为新的一次性绑定。我还使用了角度转换。 I write the follow code:
我写下面的代码:
<span data-ng-bind="::'COMMENT'|translate" />
<span>{{::'COMMENT'|translate}}</span>
<img src="shareBlack.png" alt="{{::'SHARE'|translate}}" data-ng-attr-title="::'SHARE'|translate" data-ng-click="startShare()" />
But in Batarang I can see the follow watch expressions: 但在巴塔朗,我可以看到以下手表表达式:
{{::'SHARE'|translate}} | 3.59% | 17.00ms
::'COMMENT'|translate | 2.95% | 14.00ms
What I did wrong? 我做错了什么?
EDIT in the previous version 1.2.0 with bindonce I have the following code: 使用bindonce在以前版本1.2.0中编辑我有以下代码:
<div class="box-container" bindonce>
...
<span data-bo-text="'FEED_ALLOWED_COMMENTS'|translate"/>
...
</div>
Just came across this question and the following possible answer while confronted to the same issue: 刚遇到同样的问题时遇到了这个问题和以下可能的答案:
try : 尝试:
{{::('COMMENT'|translate)}}
http://plnkr.co/edit/QogrC0bOvX8EYnmQOhpf?p=preview http://plnkr.co/edit/QogrC0bOvX8EYnmQOhpf?p=preview
Now you can do it throw this extension: 现在你可以抛出这个扩展:
translate-once directive makes use of the link function and the asynchronous resolver of $translate(). translate-once指令使用$ translate()的链接函数和异步解析器。 The directive's link function takes the translation key, looks it up asynchronously with $translate(), and once resolved, writes it to the element.
该指令的link函数接受转换键,使用$ translate()异步查找,一旦解析,就将其写入元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.