什么是NG-模型和NG绑定之间的区别 [英] What's the difference between ng-model and ng-bind

查看:217
本文介绍了什么是NG-模型和NG绑定之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在学习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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆