ng-model和data-ng-model之间的区别 [英] Difference between ng-model and data-ng-model
本文介绍了ng-model和data-ng-model之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
AngularJs 是我的新手.谁能说出ng-model和data-ng-model之间的区别?
I am new with the AngularJs. Can anyone say the difference between ng-model and data-ng-model?
使用ng-model
First Name : <input type="text" ng-model="fname" id="fname">
Second Name : <input type="text" ng-model="lname" id="lname">
使用data-ng-model
First Name : <input type="text" data-ng-model="fname" id="fname">
Second Name : <input type="text" data-ng-model="lname" id="lname">
推荐答案
最佳实践:建议使用破折号分隔的格式(例如ng-bind用于ngBind). 如果您想使用HTML验证工具,则可以使用数据前缀版本(例如ngBind的data-ng-bind).出于遗留原因,可以接受上述其他形式,但我们建议你要避免他们.
Best Practice: Prefer using the dash-delimited format (e.g. ng-bind for ngBind). If you want to use an HTML validating tool, you can instead use the data-prefixed version (e.g. data-ng-bind for ngBind). The other forms shown above are accepted for legacy reasons but we advise you to avoid them.
这篇关于ng-model和data-ng-model之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文