3

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)
      })
    }

1 Answer 1

3

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}}">
Sign up to request clarification or add additional context in comments.

2 Comments

i will accept your answer a little bit. there is an time interval for posting and accepting an answer.
Now you should be able to

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.