2

上では動作しません。例えば:角度指令は、私は、次の表を持っているテーブル

<double-rows class="ng-isolate-scope"> 

Cell1 
Cell2 

</double-rows> 

<table> 
    <thead> 
    <tr> 
     <th>Uno</th> 
     <th>Dos</th> 
    </tr> 
    </thead> 

    <!--directive template should be here--> 

    <!--/directive template should be here--> 

</table> 

あなたはここで完全なコードを見ることができます:https://plnkr.co/edit/0Z65aK?p=preview

それを動作させるには?

答えて

3

これはまったく問題ではありませんが、ブラウザがあなたが書いたHTMLをどのように解釈するかとはさらに関係します。特定のタグは他のタグにネストすることはできませんが、これは特にリスト(ulやli)やテーブル内で一般的です(ネストされたリンクやその他のものにも適用されます)。

restrict Aを使用し、テーブルで許可されている要素タイプを使用する場合はrestrict Eを使用する代わりに、それが機能します(私はディレクティブでreplace:trueを使用して、その子)

https://plnkr.co/edit/fgRzZU?p=preview

angular.module('app').directive('doubleRows', function() { 
    return { 
    templateUrl: 'template.html', 
    restrict: 'A', 
    replace:true, 
    scope: { 
     row: '=' 
    }, 
    controller: function() { 
     console.log('hi'); 
    } 
    } 
}); 

HTML

<table> 
    <thead> 
    <tr> 
     <th>Uno</th> 
     <th>Dos</th> 
    </tr> 
    </thead> 

    <!--directive template should be here--> 
    <tbody double-rows> 
    </tbody> 
    <!--/directive template should be here--> 

</table> 
関連する問題