排除删除 tr 和 td 标签?



我有以下angularjs应用程序,但由于某种原因删除了tr和td标签?

angular.module('transcludeExample', [])
.directive('pane', function() {
return {
restrict: 'E',
transclude: true,
scope: {
title: '@'
},
replace: true,
template: '<table><tbody ng-transclude></tbody></table>'
};
})
.controller('ExampleController', ['$scope', function($scope) {}]);
td {
background: red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.8/angular.min.js"></script>
<div ng-controller="ExampleController">
pre
<pane>
<tr>
<td><strong>testtest</strong></td>
</tr>
</pane>
post
</div>

浏览器似乎忽略了这个 html 代码,因为最初缺少<table>标签(所以它只显示文本(:

<tr>
<td><strong>testtest</strong></td>
</tr>

我认为唯一的解决方案是ng-transclude移动到外部元素,而不是拆分表标签。例如:jsfiddle示例

最新更新