我有一个名为dish的数组和一个表单。表单提交后,数据被推送到dish中。我尝试使用push方法将其添加到数组中,但是出现了错误。我该如何使用TypeScript进行操作? 非常感谢。 Class对象。
i have an array name dish and have a form. After the form submited, data push to dish. I have tried to use push method to add that into an array, but it's have error. How i can do that with typescript ? Thanks you very much. Class object.
export interface Dish {
id: number;
name: string;
image: string;
category: string;
label: string;
price: string;
featured: boolean;
description: string;
comments: Comment[];
}
我已经从类“comment”创建了一个名为“commentData”的对象,以接收提交表单后的所有数据。我还从类“Dish”创建了一个名为“dish”的对象。如何将对象“commentData”推入对象“dish.comments”中?
export interface Comment {
rating: number;
comment: string;
author: string;
date: string;
}
我的 git 仓库链接:https://github.com/zymethyang/Ionic_HKUST