Angular 将ngif指令应用于<;李>;元素?
我有一个这样的结构:Angular 将ngif指令应用于<;李>;元素?,angular,angular6,angular5,Angular,Angular6,Angular5,我有一个这样的结构: class GrandParent{ childsOfGrandParent: Parent[]; } class Parent{ child: Child; } class Child{ x:number y:number z:number } 如果在.ts中有这样的对象 grandParent: GrandParent[] = []; 和html格式: <ul *ngFor="let parent of grandParent.child
class GrandParent{
childsOfGrandParent: Parent[];
}
class Parent{
child: Child;
}
class Child{
x:number
y:number
z:number
}
如果在.ts中有这样的对象
grandParent: GrandParent[] = [];
和html格式:
<ul *ngFor="let parent of grandParent.childsOfGrandParent; let i = index;">
<li *ngIf="parent.child">
{{child.x}}</li>
<li *ngIf="parent.child">
{{child.y}}</li>
<li *ngIf="parent.child">
{{child.z}}</li>
</ul>
-
{{child.x}
-
{{child.y}
-
{{child.z}
如果我们不想重新绘制此结构,我该怎么办?
<ng-container *ngIf="parent.child">
<li>{{child.x}}</li>
<li>{{child.y}}</li>
<li>{{child.z}}</li>
</ng-container>
{{child.x}
{{child.y}
{{child.z}
…我已经应用了这个,我正在寻找更合适的方法。我不想为每个