angularjs - How to access this json object -


i'm using express js send data mysql. send using res.json(thedata).

in client side in console:

{    "data":[       {          "plazaid":1,          "plazaname":"fff",          "plazaaddress":"fff",          "plazacontactno":"45645",          "plazalanes":"34",          "plazastatus":"y",          "clientid":1       },       {          "plazaid":2,          "plazaname":"plaza2",          "plazaaddress":"p2",          "plazacontactno":"000",          "plazalanes":"2",          "plazastatus":"a",          "clientid":2       }    ],    "status":200,    "config":{       "method":"get",       "transformrequest":[          null       ],       "transformresponse":[          null       ],       "url":"/gettollplaza",       "headers":{          "accept":"application/json, text/plain, */*"       }    },    "statustext":"ok" } 

i store these values in array populate table using angularjs' ng-repeat this:

for(i=0;i<response.data.length;i++){     tablearray.push({         plazaid:response.data[i].plazaid,         plazaname:response.data[i].plazaname,         plazaaddress:response.data[i].plazaaddress,         plazacontactnumber:response.data[i].plazacontactnumber,         plazalane:response.data[i].plazalane,         plazastatus:response.data[i].plazastatus,         clientid:response.data[i].clientid     }); } 

when console.log array values undefined.

0: object clientid:undefined plazaaddress:undefined plazacontactnumber:undefined plazaid:undefined plazalane:undefined plazaname:undefined plazastatus:undefined 

try this. please note variable name case sensitive.

for(i=0;i<response.data.length;i++){     tablearray.push({         plazaid:response.data[i].plazaid,         plazaname:response.data[i].plazaname,         plazaaddress:response.data[i].plazaaddress,         plazacontactnumber:response.data[i].plazacontactno,         plazalane:response.data[i].plazalanes,         plazastatus:response.data[i].plazastatus,         clientid:response.data[i].clientid     }); } 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -