• 0
name Punditsdkoslkdosdkoskdo

AngularJS : Why ng-bind is better than {{}} in angular?

I was in one of the angular presentation and one of the person in the meeting mentioned ng-bind is better than {{}} binding.

One of the reason, ng-bind put the variable in the watch list and only when there is a model change the data get pushed to view, on the other hand, {{}} will interpolate the expression every time (I guess it is the angular cycle) and push the value, even if the value changed or not.

Also it is said that, if you have not much data in on the screen you can use {{}} and the performance issue will not be visible. Can someone shed some light on this issue for me?

f you are not using ng-bind, instead something like this:

  Hello, {{}}

you might see the actual Hello, {{}} for a second before is resolved (before the data is loaded)

You could do something like this

  Hello, <span ng-bind=""></span>

if that's an issue for you.

Another solution is to use ng-cloak.

  • 1
Reply Report