0
我想在我的列表中創建保存並取消保存圖標。當我點擊時,它會保存並更改圖標,然後當我再次單擊時,它會再次單擊它,然後再次鬆開並更改圖標。IONIC 2保存和未保存按鈕
在我page.html中
<ion-col>
<button id="heart" float-end (click)="savePost(i)" *ngIf="item.save == true">
<ion-icon [name]="heartFilled[i]" id="saveHeart"></ion-icon
</button>
<button id="heart" float-end (click)="deletePost(i)" *ngIf="item.save != true" >
<ion-icon [name]="heartoutline[i]" id="saveHeart" ></ion-icon>
</button>
</ion-col>
其中i是在列表中的項目的索引。
在我page.ts
savePost(i ){
this.heartFilled[i]="heart-outline"
}
deletePost(i){
this.heartoutline[i]="heart"
}
我發起的圖標變量是這樣的:
this.heartoutline.push("heart-outline")
this.heartFilled.push("heart")
我可以改變點擊的圖標,但一旦被改變不會改變他們回來。另外,我不確定如何在保存和未保存功能之間切換。