Insert response data into table

Nicoleta Wilskon

Response :

    {
    "json": {
      "response": {
        "servicetype": "1",
        "functiontype": "1000",
        "statuscode": "0",
        "statusmessage": "Success",
        "data": [{
            "groupzname": "NARAYANA E-SCHOOL1",
            "groupzcode": "CHATCH",
            "area": "JAYANAGARA 9TH BLOCK",
            "city": "BENGALURU",
            "state": "Karnataka",
            "country": "INDIA"
          },

          {
            "shortname": "School",
            "groupzname": "Smitha School",
            "groupzcode": "4353",
            "area": "fsdfsdf",
            "city": "sdfsf",
            "state": "vxcvxv",
            "country": "vxcvxv"
          }, {
            "shortname": "SerReq",
            "groupzname": "Service R",
            "groupzcode": "SerReq",
            "area": "SerReq",
            "city": "SerReq",
            "state": "SerReq",
            "country": "SerReq"
          }, {
            "shortname": "service",
            "groupzname": "Service Gropz",
            "groupzcode": "1111",
            "area": "jayanagar",
            "city": "bangalore",
            "state": "Karnataka",
            "country": "India"
          }, {
            "shortname": "Testing",
            "groupzname": "Smitha Groupz",
            "groupzcode": "5555",
            "area": "jayanagar 9th block",
            "city": "Bangalore",
            "state": "Karnataka",
            "country": "India"
          },

          {
            "shortname": "May12R2",
            "groupzname": "May12Release2",
            "groupzcode": "May12R2",
            "area": "May12R2Area: ",
            "city": "May12City",
            "state": "May12State",
            "country": "May12Country"
          }, {
            "shortname": "May12",
            "groupzname": "May12Release",
            "groupzcode": "May12",
            "area": "May12 Area",
            "city": "May12 city",
            "state": "May12 State",
            "country": "May12 Country"
          }, {
            "shortname": "Kank",
            "groupzname": "Kankar",
            "groupzcode": "knakr12",
            "area": "Kankar Area",
            "city": "Kankar city",
            "state": "Kankar state",
            "country": "Kankarcountry"
          }, {
            "shortname": "Hir",
            "groupzname": "Heera",
            "groupzcode": "Hir001",
            "area": "Hir are",
            "city": "Hir cit",
            "state": "Hir State",
            "country": "Hir India"
          },

          {
            "shortname": "Apr",
            "groupzname": "Aparajitha",
            "groupzcode": "Apraj20",
            "area": "apar area",
            "city": "apar city",
            "state": "apar state",
            "country": "apar indi"
          }
        ]
      }
    }
  }

I have to insert the above shortname, groupzname,groupzcode, area,city,country etc from this response to table dynamically.

JS :

     $scope.viewAccount = function(){
                   $scope.showListAccount = true;

              var json = {

  "json": {
    "request": {
      "servicetype": "6",
      "functiontype": "6014",
      "session_id": $rootScope.currentSession,
           "data": {
        "sortbasedon": $scope.groupzname,
        "orderby": "desc",
        "limit":10,
        "offset":10
           }

    }
  }
};

          UserService.viewListAccount(json).then(function(response) {



                 if (response.json.response.statuscode == 0 && response.json.response.statusmessage == 'Success')

                     $scope.dataArray = response.json.response.data;



                        $scope.myname = $scope.dataArray.shortname;
                        console.log($scope.myname);


            }); 
        };

If I pass above request and console the data , facing error which keep on incrementing. angular.js:68 Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting! Watchers fired in the last 5 iterations: []

S Kumar

Use the following code to display into table.

<table>                
    <tr>
        <th>groupzcode</th>
        <th>area</th>
        <th>city</th>
        <th>state</th>
        <th>country</th>
    </tr>
    <tbody>
        <tr data-ng-repeat="data in output.json.response.data">
            <td>{{ data.shortname}}</td>
            <td>{{data.groupzname}}</td>
            <td>{{data.groupzcode}}</td>
            <td>{{data.area}}</td>
            <td>{{data.city}}</td>
            <td>{{data.state}}</td>
            <td>{{data.country}}</td>
        </tr>
    </tbody>
</table>

output is the json output.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related