javascript - 如何在 ng-repeat 中将对象作为 ng-click 中的参数传递? AngularJS

标签 javascript angularjs

如何在 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/

相关文章:

javascript - 在 ng-click 函数中编码对象值

javascript - wkWebView 播放本地音频失败

javascript - setTimeout 用于 svg 时不起作用

javascript - Intl.DateTimeFormat 无法解析有效的时间值

javascript - AngularJS - 函数未定义

angularjs - Angular post json来表达

javascript - AngularJS - 在绑定(bind)中使用三元运算符和过滤器

javascript - 为什么要实现productClick事件?

javascript - 获取嵌套数组JS中对象的所有父项

angularjs - 管理 Firebase 注册邀请码