Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
两个表格单元格,而不是一个angularjs_Angularjs_Angularjs Directive_Html Table_Angularjs Ng Repeat - Fatal编程技术网

两个表格单元格,而不是一个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>

工作得很好。谢谢你!