Angular 角度2:模态开放事件

Angular 角度2:模态开放事件,angular,ng2-bootstrap,Angular,Ng2 Bootstrap,在Angular 2应用程序中,我使用: 我想知道是否有可能检测MyTestComponent中的模式打开事件?您可以声明$any,然后您就可以访问这里提到的所有这些事件 在show.bs.modal函数中,您可以将this.modalShown设置为true,它将使用@Input传递给您的子组件。您可以使用ngonchanges在子组件中侦听对此输入的更改。希望这对您有所帮助 <div bsModal #addRecordModal="bs-modal" class="modal fad

在Angular 2应用程序中,我使用:


我想知道是否有可能检测MyTestComponent中的模式打开事件?

您可以声明$any,然后您就可以访问这里提到的所有这些事件 在show.bs.modal函数中,您可以将this.modalShown设置为true,它将使用@Input传递给您的子组件。您可以使用ngonchanges在子组件中侦听对此输入的更改。希望这对您有所帮助

<div bsModal #addRecordModal="bs-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
aria-hidden="true">
<div class="modal-dialog ">
  <div class="modal-header">
  </div>
  <div class="modal-body" style="min-height: 270px;">
      <app-my-test [modal]="addRecordModal"></app-edit-record>
  </div>
  ...
@Component({...})
export class MyTestComponent implements OnInit, OnDestroy {
    @Input() modal: ModalDirective;
    ...