1
我是Angular的新手,一直在試圖製作一個動態表。Angular.js:表中的列的動態長度
用戶輸入他想要的列數,然後他可以根據需要添加多少行到每列列。
我在每列的末尾提供了一個「添加」按鈕,用於向該特定列添加新行。
我的代碼看起來有點像這樣:
<table>
<tr>
<th ng-repeat="x in setno"> SET {{x.number}}</th>
</tr>
<tr ng-repeat="z in selected">
<td> </td>
</tr>
<tr>
<td ng-repeat="x in setno">
<button ng-click="selected.push({})"> add </button>
</td>
</tr>
</table>
其中,setno是包含數字的列表:
$scope.setno[{id:"a", number:"1"},{id:"b", number:"2"},...];
和選擇具有相似的結構。
問題是,當我點擊任何列的「」添加「按鈕時,新行將被添加到所有列中。
雖然我想要添加一個新行,但只添加了「添加」按鈕的那一行。
我怎麼知道誰的「加」按鈕已被點擊?