1 回答

TA貢獻(xiàn)1878條經(jīng)驗(yàn) 獲得超4個(gè)贊
編輯:我得到你想要達(dá)到的目標(biāo)。您可以通過(guò)創(chuàng)建一個(gè)中間列表并在您的ngFor. 這樣,您只需將中間列表的引用更改為您喜歡的任何列表 onClick
export class ListPage {
transportationTypes: string[] = ['bus', 'plane'];
busSpecs: string[] = ['slow', "can't fly"];
planeSpecs: string[] = ['fast', 'can fly'];
currentList: string[] = this.transportationTypes;
itemClicked(type): void {
if (type === 'bus') {
this.currentList = this.busSpecs;
} else if(type === 'plane') {
this.currentList = this.planeSpecs;
} else {
this.currentList = this.transportationTypes;
}
}
}
在您的 HTML 中只需調(diào)用該itemClicked函數(shù)
<ion-list *ngIf="currentList">
<ion-item *ngFor="let item of currentList" (click)="itemClicked(item)">
{{item}}
</ion-item>
</ion-list>
添加回答
舉報(bào)