title: Getting/creating ViewContainerRef without ViewChild query
body: <p>I'm creating a layout with D3, and I'm trying to dynamically insert Angular components into the structure.</p>
  
  <p>I've managed to get components dynamically created using a ViewContainerRef injected into the parent component:</p>
  
  <pre><code>constructor(vcRef: ViewContainerRef...
  </code></pre>
  
  <p>I could also have got a ViewContainerRef from a html element in the template like this:</p>
  
  <pre><code>@ViewChild('htmlElementINeed', { read: ViewContainerRef }) targetConterinRef;
  </code></pre>
  
  <p>However, as I'm dynamically creating the html elements wher I need my components using D3, I cannot use the injected <code>ViewContainerRef</code>, or get a <code>ViewContainerRef</code> from the template using <code>@ViewChild</code>.</p>
  
  <p>The angular documentation <a href="https://angular.io/docs/js/latest/api/core/index/ViewContainerRef-class.html" rel="nofollow noreferrer">lists these as the two ways to access it:</a>:</p>
  
  <blockquote>
    <p>To access a ViewContainerRef of an Element, you can either place a Directive injected with ViewContainerRef on the Element, or you obtain it via a ViewChild query.</p>
  </blockquote>
  
  <p>Is there any way to manually create a ViewContainerRef, or get one for an element not defined in the template? Is it a restriction of Angular that I can only dynamically create components on a html element that is already in template at compile time?</p>