0

So, my problem is so basic but i cant solve it.

I'm trying to create dynamic table header with *ngFor.

<table>
  <tr>
        <th>Entry Warehouse</th>
        <th colspan="2" *ngFor="let data of datas">
          SomeText
        </th>
  </tr>
  <tr>
       <th>More Text</th>
       <div *ngFor="let data of datas">
         <th>A little text again</th>
         <th>A little text again</th>
       </div>
  </tr>
</table>

Anyway, this solution suicide themself at that point. If datas length more than 1, div tag is underscoring th tag in same cell. If i try another solution like this;

<table>
  <tr>
        <th>Entry Warehouse</th>
        <th colspan="2" *ngFor="let data of datas">
          SomeText
        </th>
  </tr>
  <tr>
       <th>More Text</th>
       <th *ngFor="let data of datas">A little text again</th>
       <th *ngFor="let data of datas">A little text again</th>
  </tr>
</table>

it looks like works but actually not. Because at this time the next th tag doesnt start before the previous loop ends.

1
  • 1
    Can you add your JSON data? Commented Nov 28, 2018 at 14:25

1 Answer 1

4

In angular 2+ you can use<ng-container> tags

<ng-conatiner *ngFor="let i of items">
<th>i</th>
</ng-conatiner>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.