如何访问此json对象

时间:2016-08-24 04:59:16

标签: angularjs json

我使用express js从mysql发送数据。我是使用res.json(theData)发送的。

在客户端,我在控制台中得到它:

{
   "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"
}

我将这些值存储在一个数组中,以使用angularjs'来填充表格。 ng-repeat喜欢这样:

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
    });
}

当我在console.log数组中时,值是未定义的。

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

0 个答案:

没有答案