无法将嵌套数据提取到PrimeNG表中

时间:2019-01-04 10:39:40

标签: primeng angular7 primeng-turbotable

我对 PrimeNG表非常陌生,我尝试将嵌套的json文档加载到表中,但是无法访问嵌套数组的数据。

我能够将 flatten json加载到p表中,但在嵌套的json中放大胆以获取嵌套的数据

EX:{ field: "address", header: "Address ", title: "Person Address" } 对于此代码,在地址列中获取了 [object,object]

我也尝试像字段address[0].id那样建立索引,但没有得到

此示例是从API提取json的数据

Retailers=[
        {
            "id":1,
            "name":"Preeti Mobiles",
            "address":[{
                "id": 1,
                "addressLine1":"31/A, 2nd cross, 1st floor",
                "addressLine2":"Tirumala Towers, Mejestic",
                "city":"Bengaluru",
                "state":"Karnataka",
                "country":"India",
                "pincode":500006
            },
            {
                "id": 2,
                "addressLine1":"31/A, 2nd floor",
                "addressLine2":"Hebbal",
                "city":"Bengaluru",
                "state":"Karnataka",
                "country":"India",
                "pincode":500091
            }
            ]
        },
        {
            "id": 2,
            "name": "Nanda Electronics",
            "address": [{
                "id": 1,
                "addressLine1": "78/A, 4nd cross, 1st floor",
                "addressLine2": "Kishan Empower, RR Nagar",
                "city": "Bengaluru",
                "state": "Karnataka",
                "country": "India",
                "pincode": 520006
            }
            ]

        },
        {
            "id": 3,
            "name": "Kishan Electronics",
            "address": [{
                "id": 1,
                "addressLine1": "86/A, 1nd cross, 2st floor",
                "addressLine2": "Nanda Building, Hebbala",
                "city": "Bengaluru",
                "state": "Karnataka",
                "country": "India",
                "pincode": 520036
            }
            ]
        }
    ]

键入脚本代码

ngOnInit() {
        this.person();
      }
     person(){
        this.personService.getpersonList().subscribe(data=>{
          this.person_details = data;
          console.log(this.person_details);
        });

        this.retailer_list = [
          { field: "name", header: "Name", title: "person Name" },
          { field: "address", header: "Address ", title: "person Address" }
          ];
      }
    }

0 个答案:

没有答案