Reputation: 289
I am subscribing to my data from an http get method:
getEds(): void {
this.edService.getEds()
.subscribe((eds: Education) => {
this.eds = eds.educationData;
console.log(this.eds:codeschool);
});
}
I am trying to display my courses for codeschool in an *ngFor loop but do not know how to access the data. My console log will show the entire array of objects so I know I am receiving the correct info. I've tried various syntax:
.subscribe((eds: any) => {
this.eds = eds.educationData.course;
.subscribe((eds: any) => {
this.eds = eds.educationData['codeschool'];
.subscribe((eds: any) => {
this.eds = eds.educationData.codeschool;
None of these syntax work and the log shows undefined. I found this page which has great info and what I tried to use as a baseline.
Access / process (nested) objects, arrays or JSON
However, I do not know what is wrong or why I cannot get the data I need. When I use
.subscribe((eds: any) => {
this.eds = eds.educationData;
and I log out (this.eds), my log shows:
[{…}]
0:{codeschool: Array(14), egghead: Array(6)}
length:1
__proto__:Array(0)
Beyond this I haven't been able to get the data I want...... :(
Upvotes: 0
Views: 66