什么是NG-模型和NG绑定之间的区别 [英] What's the difference between ng-model and ng-bind
问题描述
目前,我正在学习angularjs和我难以理解 NG-绑定
和 NG-模型
之间的区别
I'm currently learning angularjs and am having difficulty understanding the difference between ng-bind
and ng-model
.
谁能告诉我,他们是如何不同,当一个人应该比其他用?
Can anyone tell me how they differ and when one should be used over the other?
推荐答案
NG-绑定有单向数据绑定($范围 - >视图)。它有一个快捷键 {{} VAL}
它显示的范围值 $ scope.val
插入到HTML,其中 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-模型意表单元素里面放,并具有双向数据绑定($范围 - >视图,视图 - > $范围),例如<输入NG模型=VAL/方式>
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-模型和NG绑定之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!