Join the Stack Overflow Community
Stack Overflow is a community of 6.5 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I have a json given below

var returnObj = {
      "subscriptions": [
     {
      "subscriptionId": "ef94e4226e2b1a3c218ae5bd07273726",
      "productId": "WBP",
      "plans": [
        {
          "planId": "WBP_INCL_UPDATES",
          "attributes": [
            {
              "vintage": "2016-10",
              "url": "https://google.com",
              "release": "0.0.0",
              "expiredOn": "2016-12-23T07:33:18.093+0000"
            },
            {
              "vintage": "2016-11",
              "url": "https://yahoo.com",
              "release": "0.0.0",
              "expiredOn": "2016-12-23T07:33:18.094+0000"
            }
          ]
        }
      ]
    },
    {
      "subscriptionId": "ee94e4226e2b1a3c218ae5bd07273726",
      "productId": "POI",
      "plans": [
        {
          "planId": "POI_ARG",
          "attributes": []
        }
      ]
    }
  ]
};

I want to display it in angularJS table format output will as given below

Name URL

WBP https://google.com

WBP https://yahoo.com

share|improve this question
    
What have you tried so far? Do you have any html or Angular code written? – therobinkim 1 hour ago

Try like this

var temp=[];
returnObj.subscriptions.forEach(function(x){
   x.plans.forEach(function(y){
     y.attributes.forEach(function(z){
       temp.push({Name: x.productId, URL: z.url});
     })
   })

})
console.log(temp);

DEMO

share|improve this answer

Hope this helps you

var returnObj = {
      "subscriptions": [
     {
      "subscriptionId": "ef94e4226e2b1a3c218ae5bd07273726",
      "productId": "WBP",
      "plans": [
        {
          "planId": "WBP_INCL_UPDATES",
          "attributes": [
            {
              "vintage": "2016-10",
              "url": "https://google.com",
              "release": "0.0.0",
              "expiredOn": "2016-12-23T07:33:18.093+0000"
            },
            {
              "vintage": "2016-11",
              "url": "https://yahoo.com",
              "release": "0.0.0",
              "expiredOn": "2016-12-23T07:33:18.094+0000"
            }
          ]
        }
      ]
    },
    {
      "subscriptionId": "ee94e4226e2b1a3c218ae5bd07273726",
      "productId": "POI",
      "plans": [
        {
          "planId": "POI_ARG",
          "attributes": []
        }
      ]
    }
  ]
};


var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
   $scope.rows = []; 
  returnObj.subscriptions.forEach(function(subscription){
     subscription.plans.forEach(function(plan){
       plan.attributes.forEach(function(attribute){
         $scope.rows.push({name: subscription.productId, url: attribute.url});
       });
     });
   });
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="customersCtrl"> 

<table>
  <tr><td>Name</td><td>URL</td></tr>
  <tr ng-repeat="row in rows">
    <td>{{ row.name }}</td>
    <td>{{ row.url }}</td>
  </tr>
</table>

</div>

share|improve this answer

Here is what you need hope it helps.

angular.module('app',[]).controller('mainCtrl', function($scope){
    $scope.ctrlTest = "Applying";
    $scope.returnObj = {"subscriptions": [
{
  "subscriptionId": "ef94e4226e2b1a3c218ae5bd07273726",
  "productId": "WBP",
  "plans": [
    {
      "planId": "WBP_INCL_UPDATES",
      "attributes": [
        {
          "vintage": "2016-10",
          "url": "https://google.com",
          "release": "0.0.0",
          "expiredOn": "2016-12-23T07:33:18.093+0000"
        },
        {
          "vintage": "2016-11",
          "url": "https://yahoo.com",
          "release": "0.0.0",
          "expiredOn": "2016-12-23T07:33:18.094+0000"
        }
      ]
    }
  ]
},
{
  "subscriptionId": "ee94e4226e2b1a3c218ae5bd07273726",
  "productId": "POI",
  "plans": [
    {
      "planId": "POI_ARG",
      "attributes": []
    }
  ]
}]};
})
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app='app' ng-controller='mainCtrl'>
    <span>Name </span> <span> URL</span>
    <div ng-repeat="Obj in returnObj.subscriptions">
       <div ng-repeat="plan in Obj.plans">
        <div ng-repeat="attribute in plan.attributes">
        
        <span>{{Obj.productId}} </span><span> {{attribute.url}}</span>
    </div>
    </div>
    </div>

</div>

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.