Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: [filter:notarray] Expected array but received: 0

error

Error: [filter:notarray] Expected array but received: 0

html

Activator (a menu item) of the getConcessionaireList function.

<ion-item ng-click="getConcessionaireList()" >
</ion-item>

Input search for the lists of displayed data from $scope.concessionairesList

<input type="search" placeholder="Search" ng-model="searchQuery">
<ion-list>

Values from $scope.concessioniresList is to be displayed here when Activator is clicked.

<ion-item class="item item-icon-left" ng-repeat="x in concessionairesList track by $index | filter:searchQuery" href="#/app/encodereading/{{x.accountNumber}}">
    {{x.accountNumber}} - {{x.meterNumber}} - {{x.lastName | capitalize}}, {{x.firstName | capitalize}} {{x.middleName | initial}}
</ion-item>

js

Data that will be fetched from database using php

$scope.getConcessionaireList = function(){
      $http.get('http://localhost/test/php/getConcessionaires.php').then(function(res){
        $scope.show($ionicLoading);
        console.log(res.data);
        $scope.concessionairesList = res.data;
      }).finally(function(){
        $timeout(function(){
          $scope.hide($ionicLoading);
        }, 1000)
      })
    }
like image 969
Emjey23 Avatar asked Aug 06 '26 01:08

Emjey23


1 Answers

You are using track by $index before you are applying your filter. To resolve this, change your expression to:

<ion-item class="item item-icon-left" ng-repeat="x in concessionairesList  | filter:searchQuery track by $index" href="#/app/encodereading/{{x.accountNumber}}">
like image 128
Sajeetharan Avatar answered Aug 07 '26 14:08

Sajeetharan