Angular *ngFor获取数组对应的序列值

使用方法

    ngFor获取当前数据在数组的序号

*ngFor="let item of items; let i = index;"

实例点击删除本身

    ts

private items = ["张三","李四","王五","赵六","李七"];

deleteThis(index){
  console.log(index);
  this.items.splice(index,1) //根据数组的index来删除对应的元素
}

    html

  • {{item}} x

你可能感兴趣的:(Angular2+,知识点)