因此,想法是如果所有输入均为空白,则禁用提交按钮。你可以这样
<form name="myForm" action="#sent" method="post" ng-app> <input name="userPreference1" type="text" ng-model="shipment.userPreference1" /> <input name="userPreference1" type="text" ng-model="shipment.userPreference2" /> <input name="userPreference1" type="text" ng-model="shipment.userPreference3" /> <button type="submit" ng-disabled="!(!!shipment.userPreference1 || !!shipment.userPreference2 || !!shipment.userPreference3)">Submit</button></form>
!!str是强制转换
str为
boolean值。并且
!!null和
!!""都被评估为
false。
**[Demo](http://jsfiddle.net/9LVgr/)**
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)