我目前正在学习 AngularJS,但很难理解 ng-bind
和 ng-model
之间的区别。
谁能告诉我它们有何不同以及何时应使用其中一种而不是另一种?
最佳答案
ng-bind 具有单向数据绑定(bind)($scope --> view)。它有一个快捷方式 {{ val }}
显示范围值 $scope.val
插入到 html 中 val
是一个变量名。
ng-model 旨在放置在表单元素内部,并具有双向数据绑定(bind)($scope --> view 和 view --> $scope),例如<input ng-model="val"/>
.
关于angularjs - ng-model 和 ng-bind 有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12419619/