This HTML invites a button click:
<p><button class="btn btn-info" ng-click="ResetEventStation()">
Choose a different station</button></p>
Which invokes this function:
$scope.ResetEventStation = function()
{
localStorage.removeItem("stationId");
localStorage.removeItem("stationName");
localStorage.removeItem("isRegistrationStation");
$scope.stationId = -1;
$scope.stationName = '';
$scope.isRegistrationStation = false;
}
I can breakpoint and one-step through the function, but when I step beyond the closing brace, I get
angular.js:13236 Error: [orderBy:notarray] Expected array but received: {"customer_id":97,"event_id":6,"station_id":7,"station_name":"St. Pancras","customer_name":"mawg","event_title":"Event one","token":"20000097-6ee02241-7231-4f8d-9956-5cf5022de147"} http://errors.angularjs.org/1.5.0/orderBy/notarray?p0=%7B%22customer_id%22%…%22%2C%22token%22%3A%2220000097-6ee02241-7231-4f8d-9956-5cf5022de147%22%7D at angular.js:68 at angular.js:20410 at fn (eval at compile (angular.js:14086), :4:200) at regularInterceptedExpression (angular.js:15213) at Scope.$digest (angular.js:16655) at ChildScope.$apply (angular.js:16928) at HTMLButtonElement. (angular.js:24551) at HTMLButtonElement.dispatch (jquery-2.1.1.min.js:3) at HTMLButtonElement.r.handle (jquery-2.1.1.min.js:3)
Googling shows it to be a filter error and, sure enough, the browsers console shows this function, which I presume Angular generated for me:
(function($filter,ensureSafeMemberName,ensureSafeObject,ensureSafeFunction,getStringValue,ensureSafeAssignContext,ifDefined,plus,text
/*``*/) {
"use strict";
var fn=function(s,l,a,i){var v0,v1,v2,v3=l&&('ResetEventStation' in l);v2=v3?l:s;if(!(v3)){if(s){v1=s.ResetEventStation;}}else{v1=l.ResetEventStation;}ensureSafeObject(v1,text);if(v1!=null){ensureSafeFunction(v1,text);v0=ensureSafeObject(v2.ResetEventStation(),text);}else{v0=undefined;}return v0;};return fn;
})
I don't really understand what is happening. Can someone tell me what I am doing wrongly, and how to fix the error?
I can see that {"customer_id":97,"event_id":6,"station_id":7,"station_name":"St. Pancras","customer_name":"mawg","event_title":"Event one","token":"20000097-6ee02241-7231-4f8d-9956-5cf5022de147"}
is not an array, but an not sure why it is being referenced.
You should look for an orderBy
filter in your code and change/remove it. Since, it is trying to sort your array but instead of array you are having that object.
There are two possible ways where you can use this filter:
ng-repeat="something in someArray | orderBy: some"
$filter('orderBy')(...)
Search for these and modify them to have array instead (or remove the filter) to get rid of this error!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With