我正在研究Angular 5应用程序,我得到了具有以下数据结构的类,我需要在模板中显示,可能使用Angular Kendo UI Grid,如果没有那么样本以格式显示
我在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
}
}
尝试按{{MyClass.ResponseType.Name}}打印ResponseType名称,但Angular无法识别它
我认为你必须根据你的数据更新类属性
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;
};
}
在组件中
class Component {
items: MyClass[] = [];
assign(data) {
this.items = data;
}
}