![](/img/trans.png)
[英]how to add a new row in table in function [onClick ],and remove this attribute from the all row except the new
[英]onclick on the add the new row in the table
我剛開始使用 angular。我有一張桌子和一個按鈕。 單擊按鈕時,應在表格中添加與前一行類似的新行。我在下面添加了 stackblitz 鏈接。 我正在努力弄清楚這一點。提前致謝。
這是一個示例https://stackblitz.com/edit/angular-rs6bkq 。 您需要創建一個任意數組並使用其長度來定義要顯示的行數。 請注意放置在tr
標簽上的*ngFor
指令。 這實際上是 HTML 中用於數組中項目數的 for 循環。 因此,如果您使用函數調用更改數組的長度,則表行數將更新以反映這一點。
您可以在此處閱讀有關結構指令(如 ngFor)的更多信息 - https://angular.io/guide/structural-directives
檢查它是否有幫助: https : //stackblitz.com/edit/angular-add-new-row
我添加了一些修改以讓輸入具有不同的值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.