【发布时间】:2017-08-03 01:50:51
【问题描述】:
我想在我的列表中创建一个保存和取消保存图标。当我单击时,它会保存并更改图标,然后当我再次单击时,我再次单击它会再次取消保存并更改图标。
在我的 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")
我可以在点击时更改图标,但一旦更改就不能再改回来。另外,我不确定如何在保存和取消保存功能之间切换。
【问题讨论】:
标签: javascript android html angularjs ionic2