【发布时间】:2016-10-11 11:53:42
【问题描述】:
我是 Angular 新手,一直在尝试制作动态表格。
用户输入他想要的列数,然后他可以根据需要向
我在每列末尾提供了一个“添加”按钮,用于向该特定列添加新行。
我的代码看起来有点像这样:
<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"},...];
和selected具有相似的结构。
问题是当我点击任何列的“添加”按钮时,一个新行会添加到所有列中。
而我想要的是,仅将新行添加到已单击“添加”按钮的行中。
我如何知道点击了谁的“添加”按钮?
【问题讨论】:
标签: angularjs html-table