Angular 7 等同于 JQuery on , Angular 中的事件侦听器以查找 Modal Show
Angular 7 what is equivalent of JQuery on , event listener in Angular to find Modal Show
我正在寻找一个事件侦听器来捕捉模态显示事件,在 JQuery 上是这样的,但在 Angular 7
中是这样的
$('#modaldemo4').on('shown.bs.modal', function () {
$('#modalCloser').trigger('click')
})
我已经试过了,但是不行
this.modaldemo4.nativeElement.addEventListener('modal-shown', function () {
this.modalCloser.nativeElement.click();
this.modalCloser2.nativeElement.click();
this.routToFacilityValidationPage();
});
什么是 bootstrap 模态打开或显示事件 angular 7.
提前致谢。
您需要实际发出 modal-shown
事件。你在听它,但没有任何东西发出它。我不确定模态的 class 是什么样子,但它已经在监听 shown.bs.modal
,您也许可以监听它。
否则,如果您有一个显示它的按钮,您可以在处理模式可见性的按钮上放置一个标志。
<button (click)="openModal()"></button>
在你的 .ts 文件中是这样的:
openModal() {
this.modalVisible = true;
}
我正在寻找一个事件侦听器来捕捉模态显示事件,在 JQuery 上是这样的,但在 Angular 7
中是这样的 $('#modaldemo4').on('shown.bs.modal', function () {
$('#modalCloser').trigger('click')
})
我已经试过了,但是不行
this.modaldemo4.nativeElement.addEventListener('modal-shown', function () {
this.modalCloser.nativeElement.click();
this.modalCloser2.nativeElement.click();
this.routToFacilityValidationPage();
});
什么是 bootstrap 模态打开或显示事件 angular 7.
提前致谢。
您需要实际发出 modal-shown
事件。你在听它,但没有任何东西发出它。我不确定模态的 class 是什么样子,但它已经在监听 shown.bs.modal
,您也许可以监听它。
否则,如果您有一个显示它的按钮,您可以在处理模式可见性的按钮上放置一个标志。
<button (click)="openModal()"></button>
在你的 .ts 文件中是这样的:
openModal() {
this.modalVisible = true;
}