Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JSON处理-Javascript_Javascript_Arrays_Angularjs_Json_Angular - Fatal编程技术网

JSON处理-Javascript

JSON处理-Javascript,javascript,arrays,angularjs,json,angular,Javascript,Arrays,Angularjs,Json,Angular,我有一个包含json的脚本 $http({ url: '/mpdValidation/mpdValidate', method: "POST", data: { 'message' : mpdData } ).then(function(response) { console.log(response.data.searchResults[0].customers); $rootScope.mpdValidatedData = resp

我有一个包含json的脚本

$http({
      url: '/mpdValidation/mpdValidate',
      method: "POST",
      data: { 'message' : mpdData }
    ).then(function(response) {
    console.log(response.data.searchResults[0].customers);
    $rootScope.mpdValidatedData = response.data.searchResults[0].customers;
    var partyAddressesArray = $rootScope.mpdValidatedData['partyAddresses '];
    console.log(partyAddressesArray.length);
});
我将在一张桌子上看这个

我担心的是,这个json中几乎没有我无法迭代/处理的数组

就是

我的json

{
  "searchResults": [
    {
      "id": 1,
      "firstName": "kelly",
      "lastName": "johnson",
      "facets": {
        "totalCustomerfound": 118541
      },
      "customers": [
        {
          "score": 20,
          "fullName": "kelly kelly",
          "firstName": "kelly",
          "lastName": "kelly",
          "dob": "1963/01/22",
          "memNum": "42900711",
          "phoneList": [
            {
              "phoneType": "homephonenumber",
              "phoneExchange": "222",
              "phoneAreaCode": "111",
              "phoneNumber": "9198",
              "phoneFullNumber": "1112229198"
            },
            {
              "phoneType": "primaryphonenumber",
              "phoneExchange": "444",
              "phoneAreaCode": "333",
              "phoneNumber": "9198",
              "phoneFullNumber": "3334449198"
            }
          ],
          "partyAdresses": [
            {
              "addressType": "home",
              "address1": "22 IRON KETTLE ST",
              "zipCode": "89130-2222",
              "city": "LAS VEGAS",
              "state": "NV"
            },
            {
              "addressType": "mailing",
              "address1": "11 SANDPIPER LN",
              "zipCode": "80601-1111",
              "city": "BRIGHTON",
              "state": "CO"
            }
          ],
          "policyList": [

          ],
          "membershipList": [
            {
              "termEffectiveDate": "2015/12/16",
              "termExpirationDate": "2016/12/16",
              "contractTransactionTimeStamp": "2017/09/05 19:46:29.722",
              "policyInceptionDate": "2015/12/16",
              "policyNumber": "112233",
              "policyStatus": "INACTIVE",
              "prodTypeCode": "MSHP",
              "productCode": "MSHP",
              "memType": "PREMIER",
              "contractAddress": [

              ],
              "roleList": [
                {
                  "roleType": "PRIMARY MEMBER",
                  "sourceId": "4290011",
                  "roleStatus": "INACTIVE",
                  "roleStartDate": "2015/12/16",
                  "membershipNumber": "4290011"
                }
              ]
            }
          ]
        }
        ]
    ]
}
<table id="mpdRecordTable" st-table="display_mpd_records"
   st-safe-src="mpdValidatedData" ng-show="mpdValidatedData"
   class="table table-bordered table-striped shadow p-3 mb-5 bg-white rounded" ng-controller="mpdController">
   <caption>*MPD - Validated customer returns</caption>
   <thead class="thead-dark">
      <tr>
         <th>First name</th>
         <th>Last name</th>
         <th>Date of birth</th>
         <th>Policy number</th>
         <th>Policy status</th>
         <th>Address type</th>
         <th>Address</th>
         <th>Phone number</th>
      </tr>
   </thead>
   <tbody>
      <tr st-select-row="row" st-select-mode="multiple" ng-repeat="row in display_mpd_records">
         <td ng-bind="row.firstName"></td>
         <td ng-bind="row.lastName"></td>
         <td ng-bind="row.dob"></td>
         <td ng-bind="row.policyNumber"></td>
         <td ng-bind="row.policyStatus"></td>
         <td ng-bind="row.addressType"></td>
         <td ng-bind="row.address"></td>
         <td ng-bind="row.phoneNumber"></td>
      </tr>
   </tbody>
</table>
我的桌子

{
  "searchResults": [
    {
      "id": 1,
      "firstName": "kelly",
      "lastName": "johnson",
      "facets": {
        "totalCustomerfound": 118541
      },
      "customers": [
        {
          "score": 20,
          "fullName": "kelly kelly",
          "firstName": "kelly",
          "lastName": "kelly",
          "dob": "1963/01/22",
          "memNum": "42900711",
          "phoneList": [
            {
              "phoneType": "homephonenumber",
              "phoneExchange": "222",
              "phoneAreaCode": "111",
              "phoneNumber": "9198",
              "phoneFullNumber": "1112229198"
            },
            {
              "phoneType": "primaryphonenumber",
              "phoneExchange": "444",
              "phoneAreaCode": "333",
              "phoneNumber": "9198",
              "phoneFullNumber": "3334449198"
            }
          ],
          "partyAdresses": [
            {
              "addressType": "home",
              "address1": "22 IRON KETTLE ST",
              "zipCode": "89130-2222",
              "city": "LAS VEGAS",
              "state": "NV"
            },
            {
              "addressType": "mailing",
              "address1": "11 SANDPIPER LN",
              "zipCode": "80601-1111",
              "city": "BRIGHTON",
              "state": "CO"
            }
          ],
          "policyList": [

          ],
          "membershipList": [
            {
              "termEffectiveDate": "2015/12/16",
              "termExpirationDate": "2016/12/16",
              "contractTransactionTimeStamp": "2017/09/05 19:46:29.722",
              "policyInceptionDate": "2015/12/16",
              "policyNumber": "112233",
              "policyStatus": "INACTIVE",
              "prodTypeCode": "MSHP",
              "productCode": "MSHP",
              "memType": "PREMIER",
              "contractAddress": [

              ],
              "roleList": [
                {
                  "roleType": "PRIMARY MEMBER",
                  "sourceId": "4290011",
                  "roleStatus": "INACTIVE",
                  "roleStartDate": "2015/12/16",
                  "membershipNumber": "4290011"
                }
              ]
            }
          ]
        }
        ]
    ]
}
<table id="mpdRecordTable" st-table="display_mpd_records"
   st-safe-src="mpdValidatedData" ng-show="mpdValidatedData"
   class="table table-bordered table-striped shadow p-3 mb-5 bg-white rounded" ng-controller="mpdController">
   <caption>*MPD - Validated customer returns</caption>
   <thead class="thead-dark">
      <tr>
         <th>First name</th>
         <th>Last name</th>
         <th>Date of birth</th>
         <th>Policy number</th>
         <th>Policy status</th>
         <th>Address type</th>
         <th>Address</th>
         <th>Phone number</th>
      </tr>
   </thead>
   <tbody>
      <tr st-select-row="row" st-select-mode="multiple" ng-repeat="row in display_mpd_records">
         <td ng-bind="row.firstName"></td>
         <td ng-bind="row.lastName"></td>
         <td ng-bind="row.dob"></td>
         <td ng-bind="row.policyNumber"></td>
         <td ng-bind="row.policyStatus"></td>
         <td ng-bind="row.addressType"></td>
         <td ng-bind="row.address"></td>
         <td ng-bind="row.phoneNumber"></td>
      </tr>
   </tbody>
</table>

*MPD-经验证的客户退货
名字
姓
出生日期
保单号码
政策状态
地址类型
地址
电话号码
因为我的json中的PartyAddress是一个数组,所以它不会显示在row.address中。我需要json中的address1、address2、city、state、home addressType的zipCode作为单个字符串显示在row.address列中

同样,对于phoneNumber,家庭电话也必须是可视的


名、姓按预期填充,但地址和电话号码除外。有人能帮忙吗?

在控制器内部,您可以使用排列运算符[…数组]将数组转换为字符串,然后再将其传递到视图,有关更多信息,请查看以下链接:


在控制器内部,您可以使用排列运算符[…数组]将数组转换为字符串,然后再将其传递给视图,有关更多信息,请查看以下链接:

您可以在特定行中尝试
ng repeat
,如下所示


{{addr.address1}},{{addr.address2}}等等

类似于电话号码等

您可以在特定行中尝试
ng repeat
,如下所示


{{addr.address1}},{{addr.address2}}等等


类似地,对于phoneNumber等,

显示错误:[ngRepeat:iexp]预期的表达式形式为“集合中的项”[track by _id]”,但得到了“addr of row.partyAddresss”。对不起,我编辑了我的答案。地址在第行。PartyAddressSNP,谢谢!!:)显示错误:[ngRepeat:iexp]预期表达式的形式为“集合中的项目”[track by _id]”,但得到了“addr of row.partyAddresss”。很抱歉,我编辑了我的答案。地址在第行。PartyAddressSNP,谢谢!!:)