gpt4 book ai didi

angularjs - ng-repeat 内的按钮

转载 作者:行者123 更新时间:2023-12-02 09:12:17 25 4
gpt4 key购买 nike

我在表行上有一个中继器,其集合经常更新。表行包含一个按钮。

如果用户在更新中继器集合的同时单击该按钮,则不会触发该按钮的事件。原因似乎是用户在重新绘制按钮的同时单击...

有没有办法不更新转发器内的某些 DOM 元素(例如按钮)?

<table>
<tr>
<th>Name</th>
<th>Action</th>
</tr>
<tr ng-repeat="item in collection">
<td>{{item.name}}</td>
<td>
<button ng-click="doSomething(item)"></button>
</td>
</tr>
</table>

最佳答案

尝试使用跟踪

<tr ng-repeat="item in collection track by item.$index">

在此处搜索跟踪:https://docs.angularjs.org/api/ng/directive/ngRepeat

关于angularjs - ng-repeat 内的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24184476/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com