Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/392.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
Javascript 用复杂的JSON填充嵌套的ng repeat_Javascript_Angularjs_Json_Angularjs Ng Repeat - Fatal编程技术网

Javascript 用复杂的JSON填充嵌套的ng repeat

Javascript 用复杂的JSON填充嵌套的ng repeat,javascript,angularjs,json,angularjs-ng-repeat,Javascript,Angularjs,Json,Angularjs Ng Repeat,我试图用AngularJS的ng repeat在另一个ng repeat中填充一行多个值的td。在我尝试访问第三个嵌套对象之前,它一直在工作 对象海卡希: 对象 -renewalUIs --patentUI --property.patentApplicationNumber(这是我想要访问的) 最初我是从一个$开始的。每个函数循环遍历每个对象,然后我遇到了这个线程,它解释了循环遍历数据更有效、更容易。我的问题是我可以访问renewalUIs的属性,但是当我向我的ng repeat语法添加额外对

我试图用AngularJS的ng repeat在另一个ng repeat中填充一行多个值的
td
。在我尝试访问第三个嵌套对象之前,它一直在工作

对象海卡希:

对象

-renewalUIs

--patentUI

--property.patentApplicationNumber(这是我想要访问的)

最初我是从一个
$开始的。每个
函数循环遍历每个对象,然后我遇到了这个线程,它解释了循环遍历数据更有效、更容易。我的问题是我可以访问
renewalUIs
的属性,但是当我向我的
ng repeat
语法添加额外对象时,不会显示任何数据

此代码适用于:

<tr ng-repeat="transaction in $ctrl.transactionHistory">
    <td>
        <span ng-repeat="item in transaction.renewalUIs">{{item.renewalDueDate}}<br></span> 
    </td>
</tr>

patentUI是每个renewalUI的财产吗

如果是这种情况,ng repeat将无法正常工作。您可以使用指令ng repeat来迭代集合对象(就像数组一样)

ngRepeat指令对一个模板中的每个项目实例化一次模板 收藏

因此,代码可能会起作用

<tr ng-repeat="transaction in $ctrl.transactionHistory">
    <td>
        <span ng-repeat="item in transaction.renewalUIs">{{item.patentUI.patentApplicationNumber}}<br></span>   
    </td>
</tr>

{{item.patentUI.patentApplicationNumber}

因为RenewalUI可能是一个数组?因此,您可能需要指定索引或使用一个或多个字符串,注意您没有任何JSON。你只有一个目标。JSON是一种字符串格式@谢谢。我会调查一下,你能发布你希望迭代的
事务
示例的JSON吗?这完全可能是因为结构与您尝试的不匹配。添加了JSON,尽管已经提供了解决方案。谢谢大家,谢谢@jmltalarn。有一个RenewalUI,两个PatentuIrenewalUI是一个数组,因此是可移植的。此数组中的对象具有属性parentUI并包含一个对象,它不是一个正确的数组,在这种情况下将不会被迭代。感谢您的反馈
[  
   {  
      "renewalUIs":[  
         {  
            "patentUI":{  
               "patentApplicationNumber":"112233.4",
               "title":"A patent generated by createDummyPatentUiForSearchAddPatent()",
               "filingDate":1171411200000,
               "business":{  
                  "businessNumber":"Bo2",
                  "businessPin":3586,
                  "businessName":"Bodget and Scarper Patent Lawyers In",
                  "phoneNumber":"203141703",
                  "timezone":"(UTC-08:00) Pacific Time (US & Canada)",
                  "street":"Thats a real town name",
                  "city":"Cut and Shooper",
                  "zip":54321,
                  "isBillingAddressSame":true,
                  "billingStreet":"bStr",
                  "billingCity":"bCty",
                  "billingState":"bStt",
                  "billingZip":2222,
                  "id":1,
                  "version":48,
                  "usstate":"Texas"
               },
               "primaryApplicantName":"James Dean",
               "clientRef":"Electric Bananas",
               "shortTitle":"Jimaroo",
               "epoPatentStatus":"EMPTY",
               "lastRenewedDateExEpo":1485648000000,
               "renewalYear":7,
               "renewalStatus":"Renewal in place",
               "patentPublicationNumber":"112233.4+1",
               "notifications":null,
               "id":1,
               "version":17,
               "currentRenewalCost":1.11,
               "costBandEndDate":1501424837236,
               "renewalCostNextStage":1111111.11,
               "renewalDueDate":1488240000000,
               "filingDateUI":"Wed Feb 14, 2007",
               "notificationUIs":null,
               "costBandEndDateUI":"Sun Jul 30, 2017",
               "renewalDueDateUI":"Tue Feb 28, 2017",
               "lastRenewedDateExEpoUI":"Sun Jan 29, 2017"
            }
         },
         {  
            "patent":null,
            "activePaymentId":null,
            "fee":{  
               "renewal":null,
               "renewalFee_EUR":123.45,
               "extensionFee_EUR":234.56,
               "processingFee_USD":20.00,
               "expressFee_USD":230.00,
               "urgentFee_USD":0.00,
               "latePayPenalty_USD":0.00,
               "fxRate":0.88,
               "subTotal_USD":608.01,
               "id":2,
               "version":0
            },
            "certificate":{  
               "renewal":null,
               "certificateName":"Harry",
               "issueDate":1499778000000,
               "docPath":"hardcodedpdffolder/certificates/",
               "filename":"dummyCertificateNumber 1.pdf",
               "certificateTemplateId":"DemoCert#01",
               "id":1,
               "version":0,
               "url":"hardcodedpdffolder/certificates/dummyCertificateNumber 1.pdf"
            },
            "renewalYear":14,
            "renewalDueDate":1512086399000,
            "renewalPeriod":"Green",
            "renewalStatus":"Renewal in place",
            "renewalAttemptsMade":1,
            "id":2,
            "version":0,
            "renewalDueDateUI":"Thu Nov 30, 2017",
            "certificateUrl":"hardcodedpdffolder/certificates/dummyCertificateNumber 1.pdf",
            "patentUI":{  
               "patentApplicationNumber":"332211",
               "title":"A patent inspired by Despicable Me",
               "filingDate":1173657600000,
               "business":{  
                  "businessNumber":"Bo2",
                  "businessPin":3586,
                  "businessName":"Bodget and Scarper Patent Lawyers In",
                  "phoneNumber":"203141703",
                  "timezone":"(UTC-08:00) Pacific Time (US & Canada)",
                  "street":"Thats a real town name",
                  "city":"Cut and Shooper",
                  "zip":54321,
                  "isBillingAddressSame":true,
                  "billingStreet":"bStr",
                  "billingCity":"bCty",
                  "billingState":"bStt",
                  "billingZip":2222,
                  "id":1,
                  "version":48,
                  "usstate":"Texas"
               },
               "primaryApplicantName":"Paul Newman",
               "clientRef":"Gru",
               "shortTitle":"Steal the Moon !",
               "epoPatentStatus":"EMPTY",
               "lastRenewedDateExEpo":null,
               "renewalYear":-1,
               "renewalStatus":"Renewal in place",
               "patentPublicationNumber":"112233.4+2",
               "notifications":null,
               "id":2,
               "version":0,
               "currentRenewalCost":1.11,
               "costBandEndDate":1501424837240,
               "renewalCostNextStage":1111111.11,
               "renewalDueDate":1490914800000,
               "filingDateUI":"Mon Mar 12, 2007",
               "notificationUIs":null,
               "costBandEndDateUI":"Sun Jul 30, 2017",
               "renewalDueDateUI":"Fri Mar 31, 2017",
               "lastRenewedDateExEpoUI":""
            }
         }
      ]
   }
]
<tr ng-repeat="transaction in $ctrl.transactionHistory">
    <td>
        <span ng-repeat="item in transaction.renewalUIs">{{item.patentUI.patentApplicationNumber}}<br></span>   
    </td>
</tr>