【发布时间】:2017-03-13 10:00:54
【问题描述】:
我在 ionic 2 项目中工作,创建了滑动以删除每个工作正常的项目,还需要单击按钮删除所有项目如何从角度 2 中的列表中删除所有项目?
<button ion-button clear>Clear All</button>
<ion-item-sliding *ngFor="let note of notes">
<ion-item>
{{note.title}}
</ion-item>
<ion-item-options>
<button (click)="deleteNote(note)" danger>
<ion-icon name="trash"></ion-icon>
</button>
</ion-item-options>
</ion-item-sliding>
文件.ts
constructor( public viewCtrl: ViewController ) {
this.notes = [
{ title: 'This is notification swipe to delete' },
{ title: 'This is notification swipe to delete' }
];
}
deleteNote(note){
let index = this.notes.indexOf(note);
if(index > -1){
this.notes.splice(index, 1);
}
}
【问题讨论】:
标签: angular typescript ionic-framework ionic2 ionic3