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. 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:
<div class="box-container" bindonce>
...
<span data-bo-text="'FEED_ALLOWED_COMMENTS'|translate"/>
...
</div>
It means it's used to achieve one time binding. Example. angular.
It is tempting to do too much work in the AngularJS controller. After all, the controller is where the view first has access to JavaScript via $scope functions. However, doing this will cause you to miss out on code sharing across the site and is not recommended by AngularJS documentation.
AngularJS expressions can be written inside double braces: {{ expression }} . AngularJS expressions can also be written inside a directive: ng-bind="expression" .
Answer: C is the correct option. The ng-app directive is used to initialize the AngularJS application.
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
Now you can do it throw this extension:
translate-once
translate-once directive makes use of the link function and the asynchronous resolver of $translate(). The directive’s link function takes the translation key, looks it up asynchronously with $translate(), and once resolved, writes it to the element.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With