在 angular2 项目中使用 Bootstrap 4,在一个组件中的多个组件中但是,我的模式出现在灰色淡入淡出(背景)下方并且不可编辑。
第一个组件.html
<batopPage>
<button class="btn btn-success" (click)="lgModal.show()">Large modal</button>
<!-- Large modal -->
<div bsModal #lgModal="bs-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button class="close" (click)="lgModal.hide()" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">Large modal</h4>
</div>
<div class="modal-body">
suscipit lobortis nisl ut aliquip ex ea commodo consequat.
</div>
<div class="modal-footer">
<button class="btn btn-primary confirm-btn" (click)="lgModal.hide()">Save changes</button>
</div>
</div>
</div>
</div>
</batopPage>
第一个组件.ts
@Component({
selector: 'firstcomponent',
template: require('./firstComponent.html')
})
export class Modals {
@ViewChild('childModal') childModal: ModalDirective;
showChildModal(): void {
this.childModal.show();
}
hideChildModal(): void {
this.childModal.hide();
}
}
其他组件.html
<firstcomponent></firstcomponent>