【问题标题】:How to delete existing controls in angular?如何以角度删除现有控件?
【发布时间】:2021-04-01 12:08:14
【问题描述】:

我已经使用 ngFor 指令动态生成了角度标签。

当数组更新时,它们不会删除旧标签,而是附加新标签。

【问题讨论】:

标签: angular ngfor


【解决方案1】:

我不确定您是如何更新 tabs 数组的,但这可能会对您有所帮助。

  tabs = ['First', 'Second', 'Third'];

  addTab(selectAfterAdding: boolean) {
    this.tabs.push('Fourth');
  }

  removeTab(index: number) {
    this.tabs.splice(index, 1);
  }

【讨论】:

  • Hello

    请有代码上面的例子。我正在像这样更新标签数组
猜你喜欢
  • 2019-02-20
  • 2021-12-15
  • 2018-11-15
  • 2015-12-08
  • 2016-06-07
  • 1970-01-01
  • 2019-06-11
  • 2021-01-17
  • 2023-03-10
相关资源
最近更新 更多