【发布时间】:2018-12-10 19:51:14
【问题描述】:
我有一个数组,有一个子数组,我需要获取子数组(任务ID),我该如何获取呢?
onDeleteTask(Id: string) {
this._taskService.deleteTask(Id).subscribe(data => {
for (let i = 0; i < this.Notes.length; i++) {
console.log(this.Notes[i].Tasks.filter(this.Notes.findIndex(e => e.Id === Id)));
}
});
}
数据:
[
{
"Id":"099c3d99-8f49-4298-934c-1fc5280d6d84",
"Description":"12312",
"NoteId":"1a91f108-e869-4427-ab5e-09d2262bfe20",
"NoteTitle":"SAKI SAKI 5 DOOLLAA"
},
{
"Id":"e74455d5-5002-4ea3-9f58-653440887690",
"Description":"1",
"NoteId":"1a91f108-e869-4427-ab5e-09d2262bfe20",
"NoteTitle":"SAKI SAKI 5 DOOLLAA"
},
{
"Id":"e75d537e-fe97-4dd5-8ca3-9cce5d3a1827",
"Description":"2",
"NoteId":"1a91f108-e869-4427-ab5e-09d2262bfe20",
"NoteTitle":"SAKI SAKI 5 DOOLLAA"
}
]
我试过了,但是id不起作用
【问题讨论】:
-
你能把那个 Notes json 粘贴到这里吗
-
@NagaSaiA [{"Id":"099c3d99-8f49-4298-934c-1fc5280d6d84","Description":"12312","NoteId":"1a91f108-e869-4427-ab5e-09d2262bfe20 ","NoteTitle":"SAKI SAKI 5 DOOLLAA"},{"Id":"e74455d5-5002-4ea3-9f58-653440887690","Description":"1","NoteId":"1a91f108-e869-4427- ab5e-09d2262bfe20","NoteTitle":"SAKI SAKI 5 DOOLLAA"},{"Id":"e75d537e-fe97-4dd5-8ca3-9cce5d3a1827","Description":"2","NoteId":"1a91f108-e869 -4427-ab5e-09d2262bfe20","NoteTitle":"SAKI SAKI 5 DOOLLAA"}] 这是来自 http 请求的传入 json 代码
-
那个过滤器到底是怎么回事
-
通过编辑您的问题来输出您问题中的数据
标签: javascript arrays angular typescript