问题
In one of my project im using "https://github.com/angular-translate/angular-translate"
for static text translation in Client side.
in Controller i have code like this:
$scope.myName = serverValue.name;
in html view i have code like this :
<p>{{myName|translate}}</p>
And also i saw below code section can be used to translate the run time values.
<p translate="{{myName}}"></p>
Here my question is "Which is best and Why ? "
Note : "Before down voting please leave your comments"
回答1:
substantial edit on my previous statement.
Using the directive reduces the number of watch statements setup, and will overall provide better performance.
Source http://angular-translate.github.io/docs/#/guide/05_using-translate-directive
So use
<p translate="{{myName}}"></p>
回答2:
I agree with EDDIEC for the point of view.
But Directive works fine for static data and it wont react for dynamic data .
Filter will keep watch on the input param and it will trigger as soon as it changes.
So i feel "Filter" is the best
来源:https://stackoverflow.com/questions/25743715/how-to-include-angular-translator-in-better-way