title: Cannot read property 'createComponent'?
body: <p>Full code is:</p>
  
  <pre><code>export class FileSaveDialogComponent
    implements OnInit, AfterViewInit, OnDestroy {
     @ViewChild("target", { read: ViewContainerRef, static: true }) target;
  
      ngAfterViewInit() {
      console.log(this.target);
      const component = this.createComponent();
      const factory = this.resolver.resolveComponentFactory(component);
      this.componentRef = this.target.createComponent(factory);
    }
  
  }
  </code></pre>
  
  <p>HTML is:</p>
  
  <pre><code>&lt;div class="savefile-content" #target&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Using:</p>
  
  <pre><code>&lt;vr-savefile-dialog
    (saveCallback)="saveCallback($event)"
    [title]="'Save profile'"
    [type]="'profile'"
  &gt;&lt;/vr-savefile-dialog&gt;
  </code></pre>
  
  <p>Why I get a error message:</p>
  
  <pre><code>ERROR TypeError: Cannot read property 'createComponent' of undefined
      at FileSaveDialogComponent.ngAfterViewInit
  </code></pre>
  
  <p>and undefined in line:</p>
  
  <p><code>console.log(this.target);</code></p>
  
  <p>Create component is, that returns specific component:</p>
  
  <pre><code>    switch (this.type) {
        case "profile":
          return SaveProfileDialogComponent;
        case "project":
          return SaveProjectDialogComponent;
      }
    }
  </code></pre>