Differences between ng-bind and ng-cloak in angularjs

后端 未结 5 1484
醉梦人生
醉梦人生 2021-01-11 10:41

In this question why ng-bind is better than {{}} in angular? I understand the differences between {{}} and ng-bind. On the other hand, I can use

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-11 11:34

    In a practical sense, if you pass your model into a view from the server, then ng-cloak is fine -- when the page renders, your view data is populated. However, if you're using a more mobile-friendly approach of loading your html and loading your data and perhaps localization with an additional call, then ng-model prevents {{}} flicker between when your page loads and your data arrives. However, I find ng-model insufficient as it can't be used universally, so I generally put an ng-show on a container that exposes the view after the data has been retrieved and a flag has been set.

提交回复
热议问题