Is there performance difference between ng-bind and {{}} (interpolation)?

0

I realized that in Angular we have two ways of displaying the values in the DOM.

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

Example with braces:

<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 forms will print the values in Dom .

But in relation to these two forms, I ask:

  • Using ng-bind , being an attribute, can be more performative than using keys?

  • What are the strengths and weaknesses of using one or the other?

asked by anonymous 04.08.2016 / 22:27

1 answer

4

As this answer in the SOen , yes, there is difference, I do not know if it is significant in the final result or if it is noticeable , but using brackets ( {{}} ) is rather slow.

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

{{}} brackets, on the other hand will check and update on all $.digest() , even if this is not necessary.

    
04.08.2016 / 22:48