代码的呈现方式如下: -
指令的模板位于顶部,然后正在渲染thead,但是thead应该位于顶部。
这是HTML
<div class="panel_content">
<table summary="A table listing various other formats for this product">
<thead>
<tr>
<th scope="col">Other Formats</th>
<th scope="col" class="site amount"><span>price</span></th>
<th scope="col" class="market_place amount"><span>New from</span></th>
<th scope="col" class="market_place amount"><span>Used from</span></th>
<th scope="col" class="market_place amount"><span></span></th>
<th scope="col" class="market_place amount"><span></span></th>
</tr>
</thead>
<tbody>
<dir></dir>
</tbody>
</table>
</div>
这是指令
app.directive('dir', function() {
return {
restrict: 'E',
replace: true,
template: '<tr><td>asdf</td></tr>'
};
});
答案 0 :(得分:2)
tbody
不期望您的指令dir
标记(期望tr
)。尝试修改代码:
app.directive('dir', function() {
return {
restrict: 'A',
replace: true,
template: '<tr><td>asdf</td></tr>'
};
});
并使用
<tbody>
<tr dir></tr>
</tbody>