我正试图在ng-repeat上使用track by但我得到以下错误:
angular-1.6.4.js:14525错误:[orderBy:notarray]预期数组但收到:0 http://errors.angularjs.org/1.6.4/orderBy/notarray?p0=0 角度为1.6.4.js:66 在angular-1.6.4.js:22268 at fn(eval at compile(angular-1.6.4.js:15358),:4:433) 在trackByIdExpFn(angular-1.6.4.js:31039) 在ngRepeatAction(angular-1.6.4.js:31096) at $ watchCollectionAction(angular-1.6.4.js:17861) 在Scope。$ digest(angular-1.6.4.js:17999) 在Scope。$ apply(angular-1.6.4.js:18269) 完成后(angular-1.6.4.js:12387) at completeRequest(angular-1.6.4.js:12613)
请看我的角度代码:
<tbody class="text-align:center list-body" style="overflow-y: scroll; max-height:400px;">
<tr ng-repeat="automatch in automatched track by $index | orderBy:sortType:sortReverse | filter:search " >
<td><input id="myCheck" type="checkbox" ng-model="automatch.ReasonID" ng-change="unMatchCheckAuto(automatch)" ></td>
<td ng-show="trandateCol">{{automatch.TranDate}}</td>
<td ng-show="valudateCol">{{automatch.ValueDate}}</td>
<td ng-show="ageCol" ng-if="automatch.Age_In_Days <= slaDays" class="green-sla">{{automatch.Age_In_Days}}</td>
<td ng-show="ageCol" ng-if="automatch.Age_In_Days > slaDays" class="red-sla">{{automatch.Age_In_Days}}</td>
<td ng-show="partranCol">{{automatch.Parttrantype}}</td>
<td ng-show="amtCol" class="align-amount no-wrap">{{automatch.TranAmt | number:2}}</td>
<td ng-show="tranpartCol" class="no-wrap">{{automatch.Reference}}</td>
<td ng-show="tranpart2Col" class="no-wrap">{{automatch.Reference2}}</td>
<td ng-show="debitCol" class="align-amount no-wrap">{{automatch.Debit | number:2}}</td>
<td ng-show="creditCol" class="align-amount no-wrap">{{automatch.Credit | number:2}}</td>
<td ng-show="tranidCol" class="no-wrap">{{automatch.TranID}}</td>
<td ng-show="tranremarksCol" class="no-wrap">{{automatch.TranRemarks}}</td>
<td ng-show="filenameCol" class="no-wrap">{{automatch.Filename}}</td>
<td ng-show="datefromfilenameCol" class="no-wrap">{{automatch.DateIsManualMatch}}</td>
<td ng-show="datefromfilenameCol" class="no-wrap">{{automatch.finalmatchid}}</td>
<td ng-show="datefromfilenameCol" class="no-wrap">{{automatch.DateFromFilename}}</td>
<td ng-show="idCol">{{automatch.ID}}</td>
</tr>
</tbody>
答案 0 :(得分:0)
应该是
ng-repeat="automatch in automatched | orderBy:sortType:sortReverse | filter:search track by $index "