Arr1 [
{id: 300,
uploads: [
{idOne: value},
{idTwo: value}
]
},
{blah: value,
uploads: [
{idOne: value},
{idTwo: value}
]
}
]
This Object is being read like this
this.activatedRoute.parent.params
.switchMap((params: Params) => this.someService.getSubmissions(+params['id']))
.subscribe(submissions => console.log('subs', submissions.map(x=>x)))
results in
The Object as shown above.
And
this.activatedRoute.parent.params
.switchMap((params: Params) => this.someService.getSubmissions(+params['id']))
.subscribe(submissions => console.log('subs', submissions.map(x=>x.id)))
Displays id:300
But when I go
this.activatedRoute.parent.params
.switchMap((params: Params) => this.someService.getSubmissions(+params['id']))
.subscribe(submissions => console.log('subs', submissions.map(x=>x.uploads)))
It logs undefined. And I can not reasonably detect why.
This is within the onInit() of an Angular component.
Try this, updated the above with forEach:-
this.activatedRoute.parent.params.switchMap(params => {
this.someService.getSubmissions(+params['id']))
.subscribe(submissions => {
submissions.forEach(x=>{
if(x.id){
console.log("id",x.id);
}
if(x.uploads){
console.log("uploads",x.uploads);
}
})
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.