title: Angular - How to implement a table component with mixed content (data and form inputs)
body: <p>I'm trying to create a component which has an input field with typeahead and a table. The component will receive as @Input arguments from the parent the name of the columns and reference to a variable which will contain the data. When an element is selected from the typeahed input field, it will be added to the data array, and thus will be showed in the table.</p>
  
  <p>The thing is that, potentially, some of the columns in the table could be not data from the array, but form fields, like a dropdown-list or a text input. Using ng-content would be a good idea, but since the columns of the table that could show form fields instead of data are not fixed, it's not possible, is it? Any ideas on how to implement this?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Since it seems not clear what I'm trying to ask, I'll explain it from another point of view:
  I have a page wich has two tables, they all behave very similarly, so I want to refactor my code, creating a component for this tables. Code of the tables, very simplified:</p>
  
  <p><strong>Table 1:</strong></p>
  
  <pre><code>&lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;Article&lt;/th&gt;
          &lt;th&gt;Reason&lt;/th&gt;
          &lt;th&gt;Claimed&lt;/th&gt;
          &lt;th&gt;&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr *ngFor="let article of amountArticles; let i = index"&gt;
          &lt;td&gt;{{ article.name }}&lt;/td&gt;
          &lt;td&gt;
              &lt;select&gt;
                  &lt;option value="tooMuch"&gt;Too much&lt;/option&gt;
                  &lt;option value="tooFew"&gt;Too few&lt;/option&gt;
                  &lt;option value="notRecieved"&gt;Not Recieved&lt;/option&gt;
              &lt;/select&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;input type="number" name="claimed"&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;button type="button (click)="onDeleteAmountArticle(i)"&gt;X&lt;/button&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p><strong>Table 2:</strong></p>
  
  <pre><code>&lt;table class="table mt-4"&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;Article&lt;/th&gt;
          &lt;th&gt;Ordered&lt;/th&gt;
          &lt;th&gt;Claimed&lt;/th&gt;
          &lt;th&gt;Action&lt;/th&gt;
          &lt;th&gt;&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
      &lt;tr *ngFor="let article of notOrderedArticles; let i = index"&gt;
          &lt;td&gt;{{ article.name }}&lt;/td&gt;
          &lt;td&gt;{{ article.amount }}&lt;/td&gt;
          &lt;td&gt;
              &lt;input type="number" name="claimed"&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;select&gt;
                  &lt;option value="return"&gt;Return&lt;/option&gt;
                  &lt;option value="keep"&gt;Keep&lt;/option&gt;
              &lt;/select&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;button type="button (click)="onDeleteNotOrderedArticle(i)"&gt;X&lt;/button&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>As you can see both tables are very similar, but some of the columns have data from the <code>amountArticles</code> or <code>notOrderedArticles</code> and some other different input form fields. How would you refactor this code creating a table component which receives in some way which columns would have data from the articles object and which have HTML code (form inputs), given to the component in a similar way as ng-content works?</p>