Answers:
ng-container优于template:
<ng-container *ngIf="expression">
看到:
我在以下位置找到了一种方法:https : //angular.io/docs/ts/latest/guide/template-syntax.html# !# star-template。
您可以简单地使用<template>标记,并替换*ngIf成[ngIf]这样。
<template [ngIf]="...">
...
</template>
template标签,默认情况下,带*的角度指令前缀会创建模板标签。所以两者都是一样的[ngIf] and *ngIf
*ngIf模板中有一个元素时,如果您template自己编写,则不需要。在某些情况下,多余的元素可能会干扰。
template标签放在tr/ td标签内吗?
*ngIf="foo"等于包装<template [ngIf]="foo">标签。简而言之,template+ []== *,所以[]!= *。除了以外的*任何元素都是有道理的。 template
您不能div直接放在内tr,那样会使HTML无效。tr只能td/ th/ table元素在它里面与他们你可以有其他HTML元素。
你可能会略有不同的HTML有*ngFor过tbody与有ngIf过tr低于自己喜欢。
<tbody *ngFor="...">
<tr *ngIf="...">
...
</tr>
<tr *ngIf="!...">
...
</tr>
..
</tbody>