title: How can I close a modal in Angular 2?
body: <p>I want user click the Submit button and the modal close automatically. </p>
  
  <p>If I add <code>data-dismiss="modal"</code> in the Submit <code>&lt;button&gt;</code>, it won't run <code>submitComments()</code>.</p>
  
  <p>I tried to do something like <code>$('#myModal').modal('hide');</code>, but not succeed.</p>
  
  <p>So how can I close a modal in Angular 2? Thanks</p>
  
  <pre><code>&lt;button type="button" class="btn btn-info" data-toggle="modal" data-target="#myModal"&gt;Open Modal&lt;/button&gt;
  
  &lt;div id="myModal" class="modal fade"&gt;
       &lt;div class="modal-dialog"&gt;
          &lt;div class="modal-content"&gt;
              &lt;div class="modal-body"&gt;
                  &lt;form (ngSubmit)="submitComments()"&gt;
                      &lt;div class="form-group row"&gt;
                          &lt;label class="form-control-label col-sm-2"&gt;Comments:&lt;/label&gt;
                          &lt;div class="col-sm-10"&gt;
                              &lt;textarea class="form-control" rows="3"&gt;&lt;/textarea&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="form-group row"&gt;
                          &lt;div class="col-sm-offset-2 col-sm-10"&gt;
                              &lt;button type="submit" class="btn btn-default"&gt;Submit&lt;/button&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/form&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>.</p>
  
  <pre><code>submitComments() {
      // I want to do something like $('#myModal').modal('hide'); here.
  }
  </code></pre>