给定 JSON 对象(formData),我尝试使用 AngularJS 遍历该对象并输出RealEstateInfo和PersonalTaxInfo。对于我的生活,我似乎无法弄清楚如何获得属性名称。有任何想法吗?
顺便说一句,(键,值)不起作用。key给了我索引号,为整个对象赋值。
<ul>
<li ng-repeat="item in formsData">
{{item.value}} //What goes here to get "RealEstateInfo" the 1st loop, and "PersonalTaxInfo" the second loop?
</li>
<ul>
$scope.formData = [
{
"RealEstateInfo": [
{
"Group": "General",
"Fields": [
{
"Name": "TitleType",
"Label": "Title Type",
"Type": "dropdown",
},
{
"Name": "NameIfAvailable",
"Label": "Name if available",
"Type": "string"
}]
},
{
"Group": "Personal",
"Fields": [
{
"Name": "TitleType",
"Label": "Title Type",
"Type": "dropdown",
},
{
"Name": "NameIfAvailable",
"Label": "Name if available",
"Type": "string"
}]
}]
},
{
"PersonalTaxInfo": [
{
"Group": "General",
"Fields": [
{
"Name": "TitleType",
"Label": "Title Type",
"Type": "dropdown",
},
{
"Name": "NameIfAvailable",
"Label": "Name if available",
"Type": "string"
}]
},
{
"Group": "PersonalInfo",
"Fields": [
{
"Name": "TitleType",
"Label": "Title Type",
"Type": "dropdown",
},
{
"Name": "NameIfAvailable",
"Label": "Name if available",
"Type": "string"
}]
}]
}]