JavaScript-错误:[filter:notarray]预期的数组,但收到的是:0
作者:互联网
错误
Error: [filter:notarray] Expected array but received: 0
html
getConcessionaireList函数的激活器(菜单项).
<ion-item ng-click="getConcessionaireList()" >
</ion-item>
输入搜索$scope.concessionairesList中显示的数据的列表
<input type="search" placeholder="Search" ng-model="searchQuery">
<ion-list>
单击Activator时,此处将显示$scope.concessioniresList中的值.
<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
将使用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)
})
}
解决方法:
在应用过滤器之前,您正在使用$index跟踪.要解决此问题,请将您的表达式更改为:
<ion-item class="item item-icon-left" ng-repeat="x in concessionairesList | filter:searchQuery track by $index" href="#/app/encodereading/{{x.accountNumber}}">
标签:angularjs,ionic-framework,javascript 来源: https://codeday.me/bug/20191110/2014893.html