title: Angular2 ng-bootstrap Modal close in component
body: <p>I will close a bootstrap modal in my component via save when input is ok.
  I'm using angular v2.4.1 and <a href="https://ng-bootstrap.github.io/#/components/modal" rel="nofollow noreferrer">ng-bootstrap 1.0.0-alpha.19</a></p>
  
  <p>I've tried <a href="https://stackoverflow.com/questions/41937699/angular-2-ng-bootstrap-close-modal">this</a> solution but I get following error:</p>
  
  <blockquote>
    <p>No provider for ViewContainerRef</p>
  </blockquote>
  
  <p>I tried to add ViewContainerRef to my module.ts but I get following error:</p>
  
  <blockquote>
    <p>Type 'typeof ViewContainerRef' is not assignable to type 'Provider'</p>
  </blockquote>
  
  <p>Here the code in my component:</p>
  
  <pre><code>import { Component } from '@angular/core';
  import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
  
  @Component({
      selector: '[add-name]',
      templateUrl: '../add-name.html'
  })
  
  export class MyComponent {   
     public errorMessage: string = '';
  
     constructor(public modalActive: NgbActiveModal) {}
  
     public saveNewStuff(name: string) {
          this.errorMessage = '';
  
          if (name === '' || name === undefined) {
              this.errorMessage = 'some message';
          } else if (this.errorMessage === '') {
              this.modalActive.close();
          }
      }
  }
  </code></pre>
  
  <p>I also tried to use <a href="https://github.com/ng-bootstrap/ng-bootstrap/blob/master/src/modal/modal-ref.ts" rel="nofollow noreferrer">NgbModalRef</a> like </p>
  
  <pre><code>  constructor(public modalRef: NgbModalRef) {}
  
   public closeModal() {
      this.modalRef.close();
      this.modalRef.dismiss();
  }
  </code></pre>
  
  <p>But this is not working at all. I not even getting an error message.</p>