<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/