admin管理员组文章数量:1343359
I updated Angular on my project, from 1.4.9 to 1.5.3. And on one of the pages I'm getting this error message:
'Error: orderBy:notarray Value is not array-like', 'Expected array but received: 0'
Here is template:
<tr ng-repeat="targeting in vm.TargetingsAudience track by $index | orderBy:orderByName">
<td>
{{targeting.Name}}
</td>
<td class="au_content_descr">
<p ng-repeat="val in targeting.Values track by $index | orderBy:orderByName" class="targeting-value">{{val}}</p>
</td>
<td class="au_ico_2">
<a class="au_del au_fast_ico" ng-click="vm.removeTargeting(targeting)"><i class="glyphicon glyphicon-remove"></i></a>
<a class="au_edit au_fast_ico" ng-click="vm.editTargeting(targeting)"><i class="glyphicon glyphicon-pencil"></i></a>
</td>
</tr>
vm.TargetingsAudience - is an Array of Objects:
[{Name: "Гео", TargetingCategory: "Audience", TypeId:"Location", Values: [0: "Россия", 1: "Москва", 2: "Московская область"]}]
I updated Angular on my project, from 1.4.9 to 1.5.3. And on one of the pages I'm getting this error message:
'Error: orderBy:notarray Value is not array-like', 'Expected array but received: 0'
Here is template:
<tr ng-repeat="targeting in vm.TargetingsAudience track by $index | orderBy:orderByName">
<td>
{{targeting.Name}}
</td>
<td class="au_content_descr">
<p ng-repeat="val in targeting.Values track by $index | orderBy:orderByName" class="targeting-value">{{val}}</p>
</td>
<td class="au_ico_2">
<a class="au_del au_fast_ico" ng-click="vm.removeTargeting(targeting)"><i class="glyphicon glyphicon-remove"></i></a>
<a class="au_edit au_fast_ico" ng-click="vm.editTargeting(targeting)"><i class="glyphicon glyphicon-pencil"></i></a>
</td>
</tr>
vm.TargetingsAudience - is an Array of Objects:
[{Name: "Гео", TargetingCategory: "Audience", TypeId:"Location", Values: [0: "Россия", 1: "Москва", 2: "Московская область"]}]
Share
edited Apr 6, 2016 at 11:16
TaZz
6727 silver badges24 bronze badges
asked Apr 6, 2016 at 10:47
Максим ЛебидьМаксим Лебидь
811 silver badge3 bronze badges
2 Answers
Reset to default 11This might be related to a breaking change in angular 1.5
Filters (orderBy)
Due to 2a85a634, passing a non-array-like value (other than undefined or null) through the orderBy filter will throw an error. Previously, the input was returned unchanged, which could lead to hard-to-spot bugs and was not consistent with other filters (e.g. filter). Objects considered array-like include: arrays, array subclasses, strings, NodeLists, jqLite/jQuery collections
Try using AngularJS toArray Filter
EDIT :
Because you sad you upgraded the app, I assumed it was working before. But to make it working I think you have to switch track by and order by statements
Note: track by must always be the last expression:
<tr ng-repeat="targeting in vm.TargetingsAudience | orderBy:orderByName track by $index ">
<p ng-repeat="val in targeting.Values | orderBy:orderByName track by $index " class="targeting-value">{{val}}</p>
Change orderBy:orderByName
to orderBy:'Name'
本文标签: javascriptError 39orderBy39 when updating to Angular 153Stack Overflow
版权声明:本文标题:javascript - Error 'orderBy' when updating to Angular 1.5.3 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743667313a2518945.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论