两个表格单元格,而不是一个angularjs
我会尽可能简单地解释我的问题。我有这样的想法:两个表格单元格,而不是一个angularjs,angularjs,angularjs-directive,html-table,angularjs-ng-repeat,Angularjs,Angularjs Directive,Html Table,Angularjs Ng Repeat,我会尽可能简单地解释我的问题。我有这样的想法: <table> <tr> <th ng-repeat="ordinate in ordinatesX">{{ordinate.ordinateLabel}}</th> </tr> </table> <th>{{ordinate.ordinateLabel}}</th><th></th> <
<table>
<tr>
<th ng-repeat="ordinate in ordinatesX">{{ordinate.ordinateLabel}}</th>
</tr>
</table>
<th>{{ordinate.ordinateLabel}}</th><th></th>
<th>{{ordinate.ordinateLabel}}</th>
.directive('ngTest', function() {
return {
restrict: 'A',
replace: true,
template: '<th></th><th></th>'
}
});
因此,第一个th是写入纵坐标标签,第二个th需要为空。
但是当摘要设置为false时,我只需要这样一个选项:
<table>
<tr>
<th ng-repeat="ordinate in ordinatesX">{{ordinate.ordinateLabel}}</th>
</tr>
</table>
<th>{{ordinate.ordinateLabel}}</th><th></th>
<th>{{ordinate.ordinateLabel}}</th>
.directive('ngTest', function() {
return {
restrict: 'A',
replace: true,
template: '<th></th><th></th>'
}
});
我尝试了一些最简单的自定义指令,如:
<table>
<tr>
<th ng-repeat="ordinate in ordinatesX">{{ordinate.ordinateLabel}}</th>
</tr>
</table>
<th>{{ordinate.ordinateLabel}}</th><th></th>
<th>{{ordinate.ordinateLabel}}</th>
.directive('ngTest', function() {
return {
restrict: 'A',
replace: true,
template: '<th></th><th></th>'
}
});
但由于replace:true和根元素为tr的问题,即使这样也不起作用。
有什么想法吗?你可以结合和
ng if不会在DOM中插入元素
<table>
<tr>
<th ng-repeat-start="ordinate in ordinatesX">{{ordinate.ordinateLabel}}</th><th ng-if="ordinate.abstract" ng-repeat-end></th>
</tr>
</table>
工作得很好。谢谢你!