how to include angular translator in better way.?

岁酱吖の 提交于 2019-12-11 03:58:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!