1

When i am trying to render name in html file is it showing properly but when i am trying to get category_image.thubmail in html, getting Cannot read property 'thumbnail' of undefined error Details are given below

Json data

[
{
    "id": 22,
    "name": "Test Name",
    "slug": "test-name-english-news",
    "cataegory_image": {
        "thumbnail": "thumb Image",
        "medium": "medium image"
    }
}
]

category model file

    export interface ICategory {
  id: number;
  name: string;
  slug: string;
  category_image: {
    thumbnail: string;
    medium: string;
  };
}

HTML code

  <li *ngFor="let category of categories | async">
    {{category.name}}{{category.category_image.thumbnail}}
    <!-- <a href="#">test<img src="{{category.category_image.thumbnail}}" width="40" alt="{{category.name}}" /></a> -->
  </li>

1 Answer 1

1

property name in your JSON is different than what you have on your html.

category.category_image.thumbnail

"cataegory_image": { "thumbnail": "thumb Image", "medium": "medium image" }

there is an extra a after t in your JSON.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.