Currently, I'm working on designing a mockup app that displays data in the form of buttons in a list. I have successfully implemented most of the features but I have encountered a problem. I have initialized an array and another class to manage the data.
-items.ts
export class ItemPage {
items: Item[] = [];
constructor() {
this.items.push(
new Item(1, 'Apple', 'Green', 6, true));
this.items.push(
new Item(2, 'Banana', 'Yellow', 15, false));
}
The data class is structured like this
-item.ts
export class Item {
constructor(
id: number,
fruit: string,
color: string,
quantity: number,
onStock: boolean,
) { }
}
Currently, I'm facing an issue with items: Item[] = [];
when I run ionic serve
. The error message states
Generic type 'Item' requires 2 type argument(s)
and type Item<K extends string, T> = { [P in K]: T; } Construct a type with a set of properties K of type T
.I have tried to troubleshoot it on my own but haven't been successful. Does anyone have an idea on how to resolve this?
Thank you