<ul>
<li *ngFor="let item of items; let i = index">
{{item}}
<i (click)="deleteThis(i)">x</i>
</li>
</ul>
private items = ["张三","李四","王五","赵六","李七"];
deleteThis(index){
console.log(index);
this.items.splice(index,1) //根据数组的index来删除对应的元素
}
网友评论