当我点击它时,我想访问该元素的兄弟姐妹,然后隐藏兄弟姐妹
<ion-list class="cat-list">
<ion-item *ngFor="let cat of cats; let i=index" [ngClass]="{active: isGroupShown(i) , 'has-child': cat.nodes.length}" (click)="toggleGroup(i,cat.title)">
<span>{{cat.title}}</span>
<ul *ngIf="isGroupShown(i)">
<li *ngFor="let subItem of cat['nodes'];"><span>{{subItem.title}}</span>
</li>
</ul>
</ion-item>
</ion-list>
我的.ts文件代码:
shownGroup = null;
.
.
.
toggleGroup(group,title) {
if (this.isGroupShown(group)) {
this.shownGroup = null;
} else {
this.shownGroup = group;
this.selectedCat = [title];
};
};
isGroupShown(group) {
return this.shownGroup === group;
};
这是我的输出:
感谢。