【发布时间】:2016-11-24 06:17:03
【问题描述】:
我想包括<tr> 和<td>,显然我不能用指令来做到这一点。它一直忽略<td> 或<td>,就好像它们不存在一样。这是我想要完成的:
<my-table>
<tr>
<td>hello</td>
<td>world</td>
</tr>
</my-table>
这里是javascript:
angular.module('app', [])
.controller('Controller', ['$scope', function($scope) {
}])
.directive('myTable', function() {
return {
restrict: 'E',
transclude: true,
templateUrl: 'my-table.html'
};
});
我的表.html:
<table ng-transclude>
</table>
上面的代码导致:
<my-table class="ng-isolate-scope"><table ng-transclude="">
hello <-- no <tr> nor <td> here just plain text
world
</table></my-table>
示例:PLUNKR
【问题讨论】:
-
那些
<tr>和<td>应该放在my-dialog-close.html里面。 -
@RogerNg 这正是我不想要的。我想要一个可定制的
<tr>,但我希望它被我的指令包装。将其作为<table>的替代品@ -
没有表格的 tr 将是无效的 html。这就是将其作为文本而不是 html 的原因
-
总结了这一切,这就是我之前在 plunkr 代码中收到警告的原因。谢谢
标签: javascript html angularjs