Angularjs 如何在modal关闭前强制表单验证
我有一个角度模态形式,我正在用Bootstrap进行造型。我想在用户单击“我同意”时进行验证。(我不想提交表单,因为它是稍后将提交的更大表单的一部分。)单击按钮时如何强制进行此验证?此外,表单名称应该与较大的表单相同还是有自己的名称 模态:Angularjs 如何在modal关闭前强制表单验证,angularjs,twitter-bootstrap,bootstrap-modal,Angularjs,Twitter Bootstrap,Bootstrap Modal,我有一个角度模态形式,我正在用Bootstrap进行造型。我想在用户单击“我同意”时进行验证。(我不想提交表单,因为它是稍后将提交的更大表单的一部分。)单击按钮时如何强制进行此验证?此外,表单名称应该与较大的表单相同还是有自己的名称 模态: <form name="agreementForm" novalidate> <div class="form-group" ng-class="{ 'has-error':agreementForm.signature.$
<form name="agreementForm" novalidate>
<div class="form-group" ng-class="{
'has-error':agreementForm.signature.$invalid && !agreementForm.signature.$pristine
}">
<label class="control-label" for="signature">Signature</label>
<input type="text" id="signature" name="signature" ng-model="agreementForm.contact.signature"
placeholder="Signature (e.g., /John Doe/)" class="form-control" ng-minlength=1 ng-model-options="{ updateOn: 'blur' }" required />
<span ng-show="agreementForm.signature.$error.required && !agreementForm.signature.$pristine" class="help-block">
Please type your signature to agree</span>
</div>
<div class="modal-footer">
<button ng-click="$dismiss()" class="btn btn-warning">Cancel</button>
<button ng-click="$close()" class="btn btn-primary">I agree</button>
</div>
</form>
签名
请键入您的签名以表示同意
取消
我同意
ng submit能否解决您的问题?比如说,
<form ng-submit="$close()">
<input type="text" ng-model="signature" ng-required="true"/>
<button type="submit">Submit</button>
</form>
提交
它防止将请求发送到服务器,并且仍应在表单上执行验证