javascript - Transclude 删除 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 示例
推荐阅读
- python - How to handle and have two types of users in django
- jquery - Datepicker 不是一个函数(Jquery-UI)
- cassandra - 如何在 Cassandra 中存储动态值
- swift - 非可选 IBOutlet 返回致命错误:当从另一个 UIViewController 类引用时
- binary - 如何用verilog将二进制浮点数转换为十进制数?
- c# - 使用唯一窗口更新对象列表中的多个属性的智能方法
- weblogic - Weblogic 优雅关闭仍接受新连接
- r - R Shiny Value Function 未在 reactivePoll 中触发
- jquery - 如何解决这个问题?找不到类
- haskell - Haskell,HDBC.Sqlite3 - 如果列不存在,如何添加?