typescript - ปิดการใช้งานเหตุการณ์คลิกนอกพื้นที่โมดัลของ Bootstrap เพื่อปิดโมดัลใน Angular 4
ฉันเป็นคนใหม่ใน Angular4 ฉันกำลังใช้ bootstrap modal ในโปรเจ็กต์ของฉัน โมดัลจะถูกซ่อนเมื่อคลิกข้างนอกโมดัล นี่คือโค้ดของฉัน
//ใน html
<div bsModal #noticeModal="bs-modal" class="modal fade" tabindex="-1" role="dialog"
aria-labelledby="myLargeModalLabel"
aria-hidden="true">
<div class="modal-dialog modal-md">
<div class="modal-content">
Hello World
</div>
</div>
</div>
// ในโค้ด ts
@ViewChild('noticeModal') public noticeModal: ModalDirective;
ngAfterViewInit() {
this.noticeModal.show();
};
คำตอบ #1
โปรดเพิ่มการตั้งค่านี้ใน HTML หวังว่ามันจะช่วยแก้ปัญหาของคุณได้
<div bsModal #noticeModal="bs-modal" class="modal fade" tabindex="-1" role="dialog"
[config]="{backdrop: 'static', keyboard: false}"
aria-labelledby="myLargeModalLabel"
aria-hidden="true">
<div class="modal-dialog modal-md">
<div class="modal-content">
Hello World
</div>
</div>
</div>
