Angularjs 如果嵌套表迭代使用ng repeat时不工作,则为ng
当表内的表在该时间内动态重复时,ng if不起作用。当我在该时间内在子表中添加一行时,采用错误的父索引。我这样使用,但在输入字段中工作正常,但当ng if条件采用错误的父索引时,按钮不起作用 例如:Angularjs 如果嵌套表迭代使用ng repeat时不工作,则为ng,angularjs,Angularjs,当表内的表在该时间内动态重复时,ng if不起作用。当我在该时间内在子表中添加一行时,采用错误的父索引。我这样使用,但在输入字段中工作正常,但当ng if条件采用错误的父索引时,按钮不起作用 例如: <div id="parentdivId" ng-repeat="parent in listOfParentTables"> <table > <thead class="evlhead ingpopuphead"&
<div id="parentdivId" ng-repeat="parent in listOfParentTables">
<table >
<thead class="evlhead ingpopuphead">
<tr>
<th >A</th>
<th >B</th>
<th >C</th>
</tr>
</thead>
<tbody >
<tr ng-repeat="child in parent.childMaster" ng-if="child.status!=2">
<td >
<select id="a10" ng-model="child.a10">
<option ng-repeat="list in listMaster" value={{list.ID}}>{{list.NAME}}</option>
</select>
</td>
<td ><div class="addrembtn" ><input class="btnadd" type="button" value="+" id="addbutton10" ng-click="addNewChildRow($parent.$index,$index)"><input class="btnrem" type="button" value="-" id="deletebutton10" ng-click="removechildRow($parent.$index,$index)"></div></td>
</tr>
</tbody>
</table>
<div style="float:left;">
<button class="parentbtn" style="margin:37px 0px 0px 17px !important;width: 75px;" value="AddTable" id="basebutton" ng-click="addNewParenttable($index)">+ Gasto</button>
</div>
<div style="float:left;">
<button class="parentbtn" style="margin: 12px 0px 0px 17px !important;width: 75px;" value="AddTable" id="basebutton" ng-click="removeParenttable($index)">- Eliminar</button>
</div>
</div>
A.
B
C
{{list.NAME}
+加斯托
-Eliminar
在嵌套的ng repeat中,$index不提供正在迭代的数组中元素的索引。比如说
ng-click="addNewChildRow(listOfParentTables.indexOf(parent),parent.childMaster.indexOf(child))"
ng-click="addNewParenttable(listOfParentTables.indexOf(parent))"
indexOf总是在ng repeat中返回原始索引
希望有帮助 显示完整的表格,请参阅我的答案。当ng删除条件时,它可能会在上面的代码中对您有所帮助,但它工作正常,但我想设置该条件谢谢重播。我将尝试此项。非常感谢:)很高兴提供帮助