我有以下 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 example
关于javascript - Transclude 删除 tr 和 td 标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57603584/