0

I have a component and it contains a 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">
          <h4 class="modal-title pull-left">Large modal</h4>
          <button type="button" class="close pull-right" (click)="lgModal.hide()" aria-label="Close">
            <span aria-hidden="true">&times;</span>
          </button>
        </div>
        <div class="modal-body">
          {{current}}
        </div>
      </div>
    </div>
  </div>

I open the modal with @ViewChild('lgModal') modal; and call this.modal.show();

But i want to separate the HTML, So is it possible to call component B from component A?

yooouuri
  • 2,578
  • 10
  • 32
  • 54
  • https://stackoverflow.com/questions/37888361/ng2-bootstrap-call-modal-defined-in-child-component-from-parent-compent – yurzui Jul 02 '17 at 16:47
  • Possible duplicate of [ng2-bootstrap show/hide modal as child component](https://stackoverflow.com/questions/42735858/ng2-bootstrap-show-hide-modal-as-child-component) – Aravind Jul 02 '17 at 17:12

1 Answers1

0

I would reccomend you to create a dialog component service which you can use whereever you are. You just need to inject it as a service and use the provided methods to fill the dialog with the relevant content.

An example, just found on a Stackoverflow thread

Webworx23
  • 121
  • 2
  • 9