praveenpds
praveenpds

Reputation: 2936

how to include angular translator in better way.?

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"

Upvotes: 2

Views: 334

Answers (2)

praveenpds
praveenpds

Reputation: 2936

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

Upvotes: 0

eddiec
eddiec

Reputation: 7646

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>

Upvotes: 2

Related Questions