且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ng-model 和 ng-bind 有什么区别

更新时间:1970-01-01 07:54:42

ng-bind 具有单向数据绑定($scope --> 视图).它有一个快捷方式 {{ val }}它显示了插入到 html 中的范围值 $scope.val,其中 val 是一个变量名.

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

ng-model 旨在放在表单元素内部,并具有双向数据绑定($scope --> 视图和视图 --> $scope)例如.

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"/>.