离子收集 - 重复功能无法在指定位置显示

时间:2017-02-03 04:18:35

标签: android angularjs cordova ionic-framework

我已经构建了这个应用程序,但我无法显示此集合 - 重复。其他一切都很好。

ShowDetails.html

<ion-view  view-title="Parts Listing">
  <ion-content>
  <div ng-controller="AppCtrl2">
    <ion-list>
        <ion-item collection-repeat="part in parts">
           {{ part.PartNo }} | {{ part.UpperSpecLimit}} 
        </ion-item>
    </ion-list>
    </div>
  </ion-content>

controllers.js

.controller('AppCtrl2', function($scope, $state, $http, $window, $filter, $timeout) {
  $scope.clicker = function(task) {
    $http.get('http://localhost:8021/testfor%20host/getDetails.php?MechNo='+ task.Machine_no)
      .success(function(result) {
        $scope.parts = result;
        alert($scope.parts);
        console.log(result);
    })
      .error(function(result) {
        console.log('data error');
      })
      .then(function(result) {
        things = result.data;
      });
    $state.go('app.ShowDetails');
  };
});

来自$ http.get

的JSON回复
[{"PartNo": "test",
"DimentionName": "test",
"UpperSpecLimit": "9.00",
"Nominal": "5.00",
"LowerSpecLimit": "1.00",
"Actual": "1.2"},{
"PartNo": "test",
"DimentionName": "test",
"UpperSpecLimit": "9.00",
"Nominal": "5.00",
"LowerSpecLimit": "1.00",
"Actual": "12"},{
"PartNo": "test",
"DimentionName": "test",
"UpperSpecLimit": "9.00",
"Nominal": "5.00",
"LowerSpecLimit": "1.00",
"Actual": "5"}]

警告($ scope.parts)给出结果

enter image description here

1 个答案:

答案 0 :(得分:0)

似乎你没有获取每个对象项。因此,您只需要调用每个对象项,如下所示:

<ion-view  view-title="Parts Listing">
  <ion-content>
  <div ng-controller="AppCtrl2">
    <ion-list>
        <ion-item ng-repeat="part in parts">
          {{ part.PartNo }} | {{ part.UpperSpecLimit}} 
        </ion-item>
    </ion-list>
    </div>
  </ion-content>