Reputation: 737
I'm trying to create a Bootstrap table using two Angular components.
My code is organised as following :
componentA.html
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<componentB></componentB>
</tbody>
</table>
componentB.html
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>mdo</td>
</tr>
The result should be like this :
but it's actually like this :
However, it works fine when I put the HTML content of componentB directly in componentA html.
Thank you for your help
Upvotes: 0
Views: 102
Reputation: 4228
You are missing the scope on tr tag : <th scope="row">1</th>
Then table element in HTML just allows thead, tbody, tfoot and tr as children.
Change your componentB selector from 'componentB' to '[componentB]'
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody componentB>
</tbody>
</table>
Upvotes: 1
Reputation: 1
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">First</th>
<th scope="col">Last</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
</tr>
</tbody>
Upvotes: 0