My webpage :
Here you can see on left hand side I have set of checkboxes but also there are some repeated names which I
A better structure of your crop data according to your need would be :-
crop.data.ts
import { Crop } from "./crop.model";
export const CROPS: Crop[] = [
{
name: "Rice", // I want this Rice
checked: true,
crops: [{
district: "Thane",
subCategory: [
{
id: 1,
name: "Basmati",
checked: true
},
{
id: 2,
name: "Ammamore",
checked: true
}]
},
{
district: "Nashik",
subCategory: [
{
id: 1,
name: "Basmati",
checked: true
},
{
id: 2,
name: "Ammamore",
checked: true
}]
}
},
{
name: "Wheat",
checked: true,
crops: [{
district: "Nashik",
subCategory: [
{
id: 1,
name: "Durum",
checked: true
},
{
id: 2,
name: "Emmer",
checked: true
}
]
}]
},
{
name: "Barley",
checked: true,
crops: [{
district: "Ratnagiri",
subCategory: [
{
id: 1,
name: "Hulless Barley",
checked: true
},
{
id: 2,
name: "Barley Flakes",
checked: true
}
]
}]
}
];
Also you can keep districts array instead of districts field if subcategories for a particular crops are always same. Else you can go for this approach which i have shown. And You UI can be modiefied according to crops data i have shared accordingly.