I am not able to access the syllabus array and console it in the js console. Also how do you print in the HTML component of the angular file? I tried many ways, but I was not successful. Maybe I feel I am missing something really easy. Could you guys help me solve this? Also could you explain how do you access JSON formats using angular or typescript easily? Maybe explanations clearly would make it easier for me to work with this JSON.
[{
"State": "Tamil Nadu",
"syllabus": [
{
"board": "CBSE",
"details": [
{
"subject": "Tamil",
"LKG": true,
"UKG": true,
"I": true,
"II": true,
"III": true,
"IV": true,
"V": true,
"VI": true,
"VII": true,
"VIII": true,
"IX": true,
"X": true,
"XI": true,
"XII": true
},
{
"subject": "English",
"LKG": true,
"UKG": true,
"I": true,
"II": true,
"III": true,
"IV": true,
"V": true,
"VI": true,
"VII": true,
"VIII": true,
"IX": true,
"X": true,
"XI": true,
"XII": true
},
{
"subject": "Maths",
"LKG": true,
"UKG": true,
"I": true,
"II": true,
"III": true,
"IV": true,
"V": true,
"VI": true,
"VII": true,
"VIII": true,
"IX": true,
"X": true,
"XI": true,
"XII": true
},
{
"subject": "Physics",
"LKG": true,
"UKG": true,
"I": true,
"II": true,
"III": true,
"IV": true,
"V": true,
"VI": true,
"VII": true,
"VIII": true,
"IX": true,
"X": true,
"XI": true,
"XII": true
},
{
"subject": "Chemistry",
"LKG": true,
"UKG": true,
"I": true,
"II": true,
"III": true,
"IV": true,
"V": true,
"VI": true,
"VII": true,
"VIII": true,
"IX": true,
"X": true,
"XI": true,
"XII": true
},
{
"subject": "Biology",
"LKG": true,
"UKG": true,
"I": true,
"II": true,
"III": true,
"IV": true,
"V": true,
"VI": true,
"VII": true,
"VIII": true,
"IX": true,
"X": true,
"XI": true,
"XII": true
}
]
},
{
"board": "State board",
"details": []
}
]
},
{
"State":"Kerala"
}]
html component and TS :
<div *ngFor="let item of data"> <p>{{item.syllabus}}</p> </div>
ngOnInit() {
this.dataService.sendGetRequest().subscribe(( data: any[]) => { console.log(data); this.data = data; console.log(); });
}
NOTE : There are no errors, Just that it displays nothing
{{item.syllabus}}