title: Can I create a TemplateRef from a string?
body: <h1>The component I got</h1>
  
  <p>Let's say I have the following super simple component:</p>
  
  <pre class="lang-js prettyprint-override"><code>class MyComponent {
      @Input()
      simpleContent: string;
      @ContentChild(TemplateRef)
      content: TemplateRef&lt;any&gt;;
  }
  </code></pre>
  
  <pre class="lang-html prettyprint-override"><code>&lt;div&gt;
      &lt;div *ngIf="simpleContent; else complexContent"&gt;{{simpleContent}}&lt;/div&gt;
      &lt;ng-template #complexContent&gt;
          &lt;ng-container [ngTemplateOutlet]="content"&gt;&lt;/ng-container&gt;
      &lt;/ng-template&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>At the option of the user, it can be used like this:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;my-component simpleContent="Hello world!"&gt;&lt;/my-component&gt;
  </code></pre>
  
  <p>Or it can be used like this:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;my-component&gt;
      &lt;ng-template&gt;Hello world!&lt;/ng-template&gt;
  &lt;/my-component&gt;
  </code></pre>
  
  <p>While the second option allows for embedded HTML and thus more complex formatting, the user can choose the simple approach with just an attribute for the majority of cases.</p>
  
  <h1>Question</h1>
  
  <p>I would like to simplify the component and get rid of the if/else in the template. I imagine something like this:</p>
  
  <pre class="lang-js prettyprint-override"><code>class MyComponent {
      @ContentChild(TemplateRef)
      content: TemplateRef&lt;any&gt;;
      @Input()
      set simpleContent(value: string) {
          this.content = new TemplateRef(value);
      }
  }
  </code></pre>
  
  <pre class="lang-html prettyprint-override"><code>&lt;div&gt;
      &lt;ng-container [ngTemplateOutlet]="content"&gt;&lt;/ng-container&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Obviously this does not work, because <code>new TemplateRef(value)</code> is not possible.</p>
  
  <p><strong>Is there a way to create a basic simple template dynamically at runtime?</strong></p>