gpt4 book ai didi

html - 如何将父元素 id 作为参数传递给 ng-change

转载 作者:行者123 更新时间:2023-11-27 23:35:31 25 4
gpt4 key购买 nike

 <ul class="nav" id="usrList">
<li ng-repeat="user in users" id={{user.uid}} name={{$index}}
ng-click="fillUserForm($event)">{{user.mobile + " / " + user.email}}
<input type="checkbox" style="float:right;" ng-model="usersCheck[$index]"
ng-change="activeInactiveUser($parent.attribute.id,usersCheck[$index])"
ng-checked="usersCheck[$index]" />
</li>
</ul>

如何获取父元素 ID 以将其传递到 activeInactiveUser(parent id,"") 函数中。

最佳答案

为此使用 ng-init,因为它很冗长并提高了可读性:

<ul class="nav" id="usrList">
<li ng-repeat="user in users" ng-init="sectionIndex = $index" id={{user.uid}} name={{$index}}
ng-click="fillUserForm($event)">{{user.mobile + " / " + user.email}}
<input type="checkbox" style="float:right;" ng-model="usersCheck[$index]"
ng-change="activeInactiveUser(sectionIndex.uid,usersCheck[$index])"
ng-checked="usersCheck[$index]" />
</li>
</ul>

关于html - 如何将父元素 id 作为参数传递给 ng-change,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33996029/

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