AngularJS ng-repeat with filter - notarray error

I had initialised messages as an object.

Changing $scope.messages = {}; to $scope.messages = []; made the error go away.


Your messages must be containing the data in Object form not in the Array form.

That is why this error is being thrown. Check the doc https://docs.angularjs.org/error/filter/notarray

From the docs:

Filter must be used with an array so a subset of items can be returned. The array can be initialized asynchronously and therefore null or undefined won't throw this error.

So make sure, your $scope.messages containing data in array form not in the Object form.


queryfilter is an object not an array. So apply the ng-repeat on queryfilter as given below <tr ng-repeat = "message in messages | filter : queryFilter track by $index">

if queryfilter is array then simply use

<tr ng-repeat = "message in messages | filter : queryFilter">

track by $index is necessary whenever we loop the object