错误:[filter:notarray]预期数组但收到:

时间:2016-03-31 06:56:42

标签: javascript arrays angularjs

大家好我在尝试在搜索框中输入时过滤掉数据时收到此错误。 这是搜索

<div class="col-lg-4">

            <input type="text" placeholder="Search" ng-model="searchBox" class="form-control">
    </div>

我有一个ng-repeat,我获取数据并循环,我将其作为ng-repeat

<div ng-if="messages.data">
            <div class="history_box col-lg-12"
                 ng-repeat="x in messages.data | filter:searchBox"
                 ng-click="getSingleHistory(x)">
                    <div class="padding-top row org-info padd0">
                        <p class="org-desc">
                        <i class="icon ion-ios-paper-outline"></i>
                        <span>{{x.org_name}}</a></span></p>
                    </div>
                    <div class="row org-bottom">
                        <div class="col-lg-4">
                            <span><i class="icon ion-ios-location"></i>&nbsp;<b>{{x.org_address}}</b></span>
                        </div>
                        <div class="col-lg-4">
                            <span>
                            <!-- <i class="icon ion-calendar"></i> -->
                            <i class="icon ion-ios-calendar"></i>&nbsp;<b>{{x.ser_date}}</b>
                            </span>
                        </div>  
                        <div class="col-lg-4">
                            <span>
                            <i class="icon ion-arrow-graph-up-right"></i>&nbsp;
                            <b ng-switch on="x.sers_id">
                                <!-- <i class="icon ion-ios-information-outline"></i>&nbsp; -->
                                <b ng-switch-when="1" class="positive">Accepted</b>
                                <b ng-switch-when="2" class="assertive">Rejected</b>
                                <b ng-switch-when="3" class="balanced">Pending</b>
                            </b> 
                            </span>
                        </div>
                        <div class="col"></div>
                    </div>
            </div>
    </div>

这是我从请求获得的数据:

 data: Object
    0: {ser_id: "108", sers_id: "1", ser_hr: "12", ser_date: "", org_name: "Neymar Football Foundations", …}
    1: {ser_id: "109", sers_id: "1", ser_hr: "5", ser_date: "", org_name: "Xing Fao Foundations", …}
    3: {ser_id: "114", sers_id: "3", ser_hr: "5", ser_date: "", org_name: "Sumidra Foundations", …}

这给了我预期数组的角度误差。但这是json数组吗?

这是控制器

      var req = $http.get('http://eservicetracker.com/api/services/getServiceList.php?id='+$sessionStorage.user_id);
      req.success(function(data,status,header,config){
          $scope.messages = data;
          console.log("service history data");
          console.log(data);
          //$ionicLoading.hide();
      })

你能指导我做错的事吗?谢谢。

0 个答案:

没有答案