2016-08-31 65 views
1

代碼呈現如下形式: -通過'template'指令添加的行被添加到表格的頂部?

指令的模板位於頂部,然後呈現該副本,但副本預計位於頂部。

這裏是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>' 
      }; 
}); 

回答

2

tbody不指望你的指令dir標籤(預計tr)。嘗試修改,如代碼:

app.directive('dir', function() { 
      return { 
       restrict: 'A', 
       replace: true, 
       template: '<tr><td>asdf</td></tr>' 
      }; 
}); 

,並使用

<tbody> 
    <tr dir></tr> 
</tbody>