Summary of JSON data:
{
"courses_purchased_count": 0,
"featured_lesson": {
"lesson": {
"id": 290,
"name": "Christmas Test #290",
"course": {
"id": 43,
"name": "Christmas Test",
"description": "",
"teacher": {
"id": 4,
"name": "Sandy's Teacher",
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0179787b41722f626e6c">[email protected]</a>",
"role": "TEACHER",
"token": "xyz",
"about": "Blah blah blah ",
"phone": "2222222222",
"image_url": "xyz",
"payment_information": {}
},
"image": "xyz",
"cover_image": "xyz",
"course_type": "WEEKLY_ONGOING",
},
"status": "NEXT_AVAILABLE"
}
}
The goal is to map this data into classes defined in models.ts using the Cerialize Library.
models.ts
// Models and utility methods are defined here
// for deserialization using Cerialize Library
In the homepage component, the data from the lesson object or course object should be displayed as {{featured_lesson.lesson.name}} or {{featured.lesson.course.name}}. However, an error is encountered:
ERROR TypeError: Cannot read property 'name' of undefined
The code snippets for the homepage components are also provided for reference.
Solution and guidance are sought as the learner encounters difficulties while working with Angular. Any help would be greatly appreciated. Thank you!