title: How do I wait for response from an Angular bootstrap modal window before executing next function?
body: <p>I am trying to create a proof window for the user to validate their input before committing their data into the db. </p>
  
  <p>The bootstrap modal window works, but if I put the func x() in line on the (click)= for the button, the x() executes while the modal is displayed. </p>
  
  <p>The other difficulty is I am trying to use the modal window for three potential db update requests (delete, post, or put), so x() needs to be dynamic depending on which button opened the modal window.</p>
  
  <p>The bootstrap modal window works, but if I put the func x() in line on the (click)= for the button, the x() executes while the modal is displayed. </p>
  
  <p>The other difficulty is I am trying to use the modal window for three potential db update requests (delete, post, or put), so x() needs to be dynamic depending on which button opened the modal window.</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;span *ngIf="!isCurrent"&gt;
                                      &lt;button class="entry" id="add" (click)="openProofWindow(proof, 'add');"&gt;Add&lt;/button&gt;&amp;nbsp;&amp;nbsp;
                                  &lt;/span&gt;
                                  &lt;span *ngIf="isCurrent"&gt;
                                      &lt;button class="entry" id="update" (click)="openProofWindow(proof, 'update');"&gt;Update&lt;/button&gt;&amp;nbsp;&amp;nbsp; &lt;!--updateRequest();--&gt;
                                      &lt;button class="entry" id="delete" (click)="openProofWindow(proof, 'delete');"&gt;Delete&lt;/button&gt;&amp;nbsp;&amp;nbsp;
                                  &lt;/span&gt;
  </code></pre>
  
  <p>ts code</p>
  
  <pre><code> openProofWindow(content, target): void {
   this.modalService.open(content, target);
  </code></pre>
  
  <p>I have tried: </p>
  
  <pre><code>(click)="openProofWindow(proof, 'add');addRecord();"
  </code></pre>
  
  <p>but this executes before the modal is closed.</p>
  
  <p>This is the modal window (HTML) </p>
  
  <pre><code>&lt;div class="modal-header container"&gt;
          &lt;div class="row"&gt;
              &lt;h4 class="modal-title col-7"&gt;Proof Copy&lt;/h4&gt;
              &lt;button type="button" class="btn col-2 btn-modal" aria-label="no" (click)="modal.dismiss('cancel click')"&gt;
                      &lt;span aria-hidden="true"&gt;No&lt;/span&gt;
                  &lt;/button&gt;
              &lt;button type="button" class="btn col-2 btn-modal btn-success" aria-label="ok" ngbAutofocus (click)="modal.close('Ok click');"&gt;
                  &lt;span aria-hidden="true"&gt;Ok&lt;/span&gt;
              &lt;/button&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>Nothing should happen until the user selects Ok or No. </p>
  
  <p>If the users selects OK, depending on whether the modal was opened as an Add, Delete, or Update (put, delete, post) request, the appropriate function should be called - and the modal window closed.</p>