情况看起来是这样的。收到 API 的响应后,我需要动态填充 mat-table。作为响应 JSON,在 json 数组“文件”中有那些匿名 json 对象。
"files": [
{
"title": "dummy",
"link": "https://t1.mogree.com/backmeister_content/pdfs/presentation/31347009705473837693867181531764_a.pdf",
"attachment": "dummy-atachment_name.pdf",
"userTypes": [
"ADM",
"INT"
],
"itemid": "31347009705473837693867181531764_a.pdf",
"type": 17,
"itemproviderid": 0,
"detailtype": 0
},
{
"title": "dummy",
"link": "https://t1.mogree.com/backmeister_content/pdfs/presentation/46728595498675807527841664269653_a.pdf",
"attachment": "dummy-atachment_name.pdf",
"userTypes": [
"ADM",
"INT"
],
"itemid": "46728595498675807527841664269653_a.pdf",
"type": 17,
"itemproviderid": 0,
"detailtype": 0
}
我不知道如何在这个表的这个 imtems 上设置 observable。我刚刚得到“文件”项目。我需要访问那些匿名对象。现在我的请求函数如下所示:
ngOnInit() {
this.apiService.getAttachments()
.map(data => data['detailresponse'])
.map(data => data['files'])
.subscribe(files => {
});
}
我需要访问以下字段:“title”、“link”、“itemId”。也许我需要在 subscribe() 中进行第二个 observable ?