0

I am facing an issue while displaying the nested data inside the ng-repeat. I get data for the first 4 fields but those which are more nested like the label and onwards field data do not show up. the last 5 fields appear to be empty and does not fetch the data. Will be glad if anyone could help troubleshoot the issue.

<!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>
attached images are the responses if json data

enter image description here

enter image description here

5
  • 1
    Please post the response JSON rather than exposing api credentials. Commented Jul 31, 2021 at 12:16
  • the json response is too long to post here Commented Jul 31, 2021 at 16:05
  • Can you give a minimal sample of the response? I'd highly recommend removing the Bearer token from the description Commented Jul 31, 2021 at 18:43
  • removed the authorization token and added the images of json responses Commented Aug 1, 2021 at 16:38
  • The </tr> in <tr ng-repeat="x in myWelcome"></tr> is ending the scope of your 'x' in your ng-repeat so that any html after </tr> has no clue what 'x'. You need to figure out a way to include the following <tr ng-repeat='y in x.items'> within that first <tr> block. One suggestion is take your JSON, remodel it so that there is only 1 ng-repeat. Use ng-ifs when you havent shown those item rows yet. Commented Aug 2, 2021 at 19:09

0

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.