【问题标题】:Typescript catch bootstrap 4 modal open eventTypescript catch bootstrap 4 模态打开事件
【发布时间】:2020-07-19 08:37:16
【问题描述】:

我正在尝试在引导模型打开时执行一些代码,但我尝试的一切都不起作用。 模态:

<div class="modal fade" id="mobileModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
    aria-hidden="true" data-keyboard="false" data-backdrop="static" >

打字稿:

@ViewChild('mobileModal') mobileModal: ElementRef;

ngAfterViewInit() {
    $(this.mobileModal.nativeElement).on('hidden.bs.modal', () => {
      console.log("TESTTESTTEST")
    });
    $(this.mobileModal.nativeElement).on('shown.bs.modal', () => {
      console.log("TESTTESTTEST")
    });
    $("#mobileModal").on('shown', function () {
      console.log("TESTTESTTEST")
    });
  }

我看过但没用的其他问题:

Hook to bootstrap 4 modal show / hide events from Typescript

Capture close event on Bootstrap Modal

Calling a function on bootstrap modal open

【问题讨论】:

  • 为什么使用 jQuery 和 Angular?
  • 因为我正在试一试你知道如何捕捉那个事件吗?

标签: jquery html angular typescript bootstrap-4


【解决方案1】:

使用带有角度指令的 Hostlistener。

关注article

Stackblitz example

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-01-09
    • 1970-01-01
    • 1970-01-01
    • 2019-03-17
    • 2021-11-21
    • 1970-01-01
    • 2018-04-10
    相关资源
    最近更新 更多