ng 重复嵌套循环

时间:2021-07-31 12:07:37

标签: json angularjs angularjs-ng-repeat nested-loops

在 ng-repeat 中显示嵌套数据时遇到问题。我获得了前 4 个字段的数据,但那些更像标签和以后的字段数据嵌套的字段没有显示。最后 5 个字段似乎为空并且不获取数据。如果有人可以帮助解决问题,我们会很高兴。

<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>


<body>

  <div ng-app="myApp" ng-controller="myCtrl">

    <!-- <p>Today's welcome message is:</p> -->


    <table border="2">
      <tr>
        <th>deliveryRecipient</th>
        <th>Pick Up Locality</th>
        <th>Delivery Locality</th>
        <th>Created On</th>
        <th>Name</th>
        <th>category</th>
        <th>Item Price</th>
        <th>Weight</th>
        <th>Qty</th>
        <th>Action</th>

      </tr>
      <tr ng-repeat="x in myWelcome">
        <td>{{x.deliveryRecipient}}</td>
        <td>{{x.pickupLocality}}</td>
        <td>{{x.deliveryLocality}}</td>
        <td>{{x.createdOn}}</td>
        <td>{{x.label}}</td>
        <td>{{x.category}}</td>
        <td>{{x.actualPriceLabel}}</td>
        <td>{{x.weight}}</td>
        <td>{{x.quantity}}</td>
        <td><button onclick="showgraphqldata()" type="button" class="view">View</button></td>

      </tr>
      <td ng-repeat="y in x.items">
      <td>
        <tr ng-repeat="z in y">
          <td>{{z.label}}</td>
          <td>{{z.category}}</td>
          <td>{{z.actualPriceLabel}}</td>
          <td>{{z.weight}}</td>
          <td>{{z.quantity}}</td>

        </tr>
        <input type="hidden" value="{{x.uid}}" />
      
    </table>
  </div>


  <!-- <p>The $http service requests a page on the server, and the response is set as the value of the "myWelcome"
    variable.</p> -->

  <script>

    var app = angular.module('myApp', []);
    app.controller('myCtrl', function ($scope, $http) {
      $http({
        method: "GET",
        url: "https://api-stg.martcart.pk/api/v1/merchants/incomingOrders?archived=false&isIncomingOrders=true&isPurchaseOrders=true&loadItems=true&pageNumber=1&recordsPerPage=100&statusIn=NEW,VIEWED",
        headers: {
          datatype: 'JSON',
          
          , 'Content-Type': 'application/json'
        }
      }).then(function mySuccess(response) {

        $scope.myWelcome = response.data;

      }, function myError(response) {
        $scope.myWelcome = response.statusText;
      });
    });
  </script>
  <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  <script>
    $(document).on('click', '.view', function () {

      var uid = $(this).parent().prev().val();
     
  </script>
</body>

</html>
附加的图像是 json 数据的响应

enter image description here

enter image description here

0 个答案:

没有答案