AngularJS - Why is ng-bind faster than expressions?

前端 未结 2 759
独厮守ぢ
独厮守ぢ 2021-02-20 05:01

From this question and this answer, it seems that using expressions will cause the value to be evaluated from scratch every time. But I\'ve searched the documentation and tutori

2条回答
  •  南方客
    南方客 (楼主)
    2021-02-20 05:27

    The major difference between ng-bind and {{}} is that ng-bind creates a watcher for variable passed to it(i.e. name as in above example), while curly brackets({{}}) will (store the entire expression in memory i.e. }perform dirty-checking and refreshing the expression in every digest cycle even if it is not required. ng-bind will only apply when the value passed is changing actually. for more details refer below link: http://www.ufthelp.com/2015/11/difference-between-and-ng-bind-in.html

提交回复
热议问题