AngularJS关于{{}}ng-model和ng-bind

AngularJS 关于ng-model和ng-bind还有{{}}

 

What's the difference between ng-model and ng-bind

 

ng-bind has one-way data binding ($scope --> view). It has a shortcut $scope.val inserted into html where val is a variable name.

ng-model is intended to be put inside of form elements and has two-way data binding ($scope --> view and view --> $scope) e.g. <input ng-model="val"/>.

ng-bind是从$scope -> view的单向绑定
ng-modle是$scope <-> view的双向绑定


<p>{{text}}</p>

<p ng-bind="text"></p>

通常是应用中的index.html,其。而使用第二站方法的视图不会遇到这种问题。

所以,对于index.html页面中的数据绑定操作,建议采用ng-bind。那么在数据加载完成之前用户就不会看到任何内容。

posted @ 2018-01-04 18:08  众星拱月  阅读(117)  评论(0编辑  收藏  举报