0

I am working on Angular 5 application and I got class with following data structure, that I need to display in template, possibly using Angular Kendo UI Grid if not then sample to display in format

I got following class data in json

export class MyClass{
ConsultationId: string;
ResponseType: {
    id: string;
    Name:string;
};
TotalResponses: string;
TotalNewResponses:string;
TotalReviewResponses:string;
TotalCompletedResponses:string;
responsesAbstract: {
    ResponseId: string;
    ConsultationId: string;
    ResponseTypeId:string;
    RespondentId:string;
    ResponseCurrentStatus:string
}

}

screen shot of json data

enter image description here

In attempt to print ResponseType Name by {{MyClass.ResponseType.Name}} but Angular didn't recognise it

5
  • Do you have an instance in your component like myClass: MyClass;? Then you only have to call {{myClass.ResponseType.Name}} in your HTML Commented Mar 5, 2018 at 14:39
  • i have update json out screen shot in my question, and no I don't have myClass:MyClass, Commented Mar 5, 2018 at 14:40
  • are you sure about this case of you properties ? Commented Mar 5, 2018 at 14:44
  • yes, I am sure.. Commented Mar 5, 2018 at 14:45
  • Class has ResponseType property but in object its responseType iin camel case ! Commented Mar 5, 2018 at 14:46

1 Answer 1

1

I think you have to update you class properties based on your data

export class MyClass {
  consultationId: string;
  responseType: {
    id: string;
    name: string;
  };
  totalResponses: string;
  totalNewResponses: string;
  totalReviewResponses: string;
  totalCompletedResponses: string;
  responsesAbstract: {
    responseId: string;
    consultationId: string;
    responseTypeId: string;
    respondentId: string;
    responseCurrentStatus: string;
  };
}

and in component

class Component {
  items: MyClass[] = [];

  assign(data) {
    this.items = data;
  }
}
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.