我有几个文本输入,我需要以bootstrap 3模态形式验证,我使用Angular 5.我想只有在所有验证都成功的情况下关闭模态表单。如果验证失败,它应该保持原样,单击按钮。
其他:赌场
https://plnkr.co/edit/VgLArC3RkKMgXOhAPGei?p=preview
我想知道如何避免使用typescript从Angular中关闭模态形式。感谢您的帮助。
你可以简单地使用<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>
<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<p>On click of validate, this modal form should not get closed if text input is empty. It should get closed only if text input is not empty.</p>
<input type="text">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Validate</button>
</div>
</div>
</div>
</div>
每当你想要隐藏模态。我已经更新了它将检查输入值是否存在的代码,然后只有它将关闭。
$('#myModal').modal('hide');
希望这可以帮助。