Is there a difference in performance between ng-bind and {{ }} (Interpolation)?

Asked

Viewed 820 times

0

I realized that in Angular we have the two ways to display values in the DOM.

One is using the keys {{}}, and others, is using the attribute ng-bind.

Keyed example:

<div ng-repeat="moderador in ['bigown', 'rray']">
  {{ moderador }}
</div>

Example with ng-bind:

<div ng-repeat="moderador in ['bigown', 'rray']" ng-bind="moderador">
</div>

Both of the above ways will print the values in the Dom.

But in relation to these two forms, I ask:

  • Use ng-bind, because it is an attribute, it can be more performatic than using keys?

  • What are the points for and against using one or the other?

  • Kindly, who gave the negative, could present the problem in the question? Thus, I could improve her content by helping anyone who has doubts to be qualified in Saná them

1 answer

4


As stated in Soen, yes, there is difference, I do not know if it is significant in the final result or if it is noticeable, but use the "Brackets" ({{}}) is yes slower.

The ng-bind is a directive and puts an "observer" on the variable that was passed, thus the ng-bind only applicable when the value passed is actually change.

The "Brackets" {{}}, on the other hand will check and update on all $.digest(), even if that is not necessary.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.