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

前端 未结 12 872
灰色年华
灰色年华 2020-11-22 07:19

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 re

12条回答
  •  生来不讨喜
    2020-11-22 07:46

    Basically the double-curly syntax is more naturally readable and requires less typing.

    Both cases produce the same output but.. if you choose to go with {{}} there is a chance that the user will see for some milliseconds the {{}} before your template is rendered by angular. So if you notice any {{}} then is better to use ng-bind.

    Also very important is that only in your index.html of your angular app you can have un-rendered {{}}. If you are using directives so then templates, there is no chance to see that because angular first render the template and after append it to the DOM.

提交回复
热议问题