如何在 ng-repeat 中将对象作为 ng-click 中的参数传递?
示例:
<tr data-ng-repeat="table in tables">
<td>{{ table.name }}</td>
<td>{{ isActive(table.active) }}</td>
<td>{{ table.initialDate }}</td>
<td>{{ table.finalDate }}</td>
<td>
<button data-ng-click="updateTable(table)">Update</button>
</td>
</tr>
Inside the ng-click updateTable(HERE), I want to pass my object table.
有人可以帮助我吗?
最佳答案
在你的 component.html 中编辑你的代码,如下所示:
<td><button (click)=updateTable(table)>Update</button></td></tr>
然后在你的 typescript 代码中声明函数
updateTable(table){
console.log(table); //write your own code here!.
}
关于javascript - 如何在 ng-repeat 中将对象作为 ng-click 中的参数传递? AngularJS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28421761/