option.ts
export class Option {
id_cat: number;
name_cat: string;
image_cat: string;
option_sub : {
id_sub: number;
name_sub: string;
icon_sub: string;
ref_id_cat: number;
}
}
在Json
{"id_cat":4,
"name_cat":"Food",
"image_cat":"","option_sub":[{"id_sub":6,"name_sub":"American Food","icon_sub":"icon ion-pizza","ref_id_cat":4}]}
我想创建MegaMenu
Angular2中的type_sub T_T是什么类型
option_sub :Array<{
id_sub: number;
name_sub: string;
icon_sub: string;
ref_id_cat: number;
}>;
答案 0 :(得分:1)
您可以创建另一个Typescript类:
export class Option {
id_cat: number;
name_cat: string;
image_cat: string;
option_sub : OptionSub[];
}
export class OptionSub {
id_sub: number;
name_sub: string;
icon_sub: string;
ref_id_cat: number;
}