I've embarked on an exciting project to develop a cascading dropdown box filter, and it's proving to be quite challenging.
I'm taking it step by step to ensure clarity. I have obtained a JSON file containing the data required to populate dependent dropdown boxes.
{"data":
{"events":
{"type":"cart_update",
"properties":
[{"property":"product_id","type":"string"},
{"property":"variant_id","type":"string"},
{"property":"category_level_1","type":"string"},
{"property":"category_level_2","type":"string"},
{"property":"category_level_3","type":"string"},
{"property":"product_list","type":"string"},
{"property":"action","type":"string"}]},
{"type":"view_item",
"properties":
[{"property":"product_id","type":"string"},
{"property":"variant_id","type":"string"},
{"property":"category_level_1","type":"string"},
{"property":"category_level_2","type":"string"},
{"property":"category_level_3","type":"string"}]}]},"success":true}
To aid in navigating my JSON file effectively, I've created interfaces. Let me know if this is correct:
export interface DataInterface {
events: Array<EventInterface>;
success: boolean;
}
export interface EventInterface {
type: string;
properties: Array<PropsInterface>;
}
export interface PropsInterface{
property: string;
type:string;
}
@Injectable({
providedIn: 'root'
})
export class DataService {
constructor(private http: HttpClient) { }
getData() {
return this.http.get('./assets/data.json')
}
}
The next challenge I face is how to populate dropdown boxes with the various event[type] and properties[property], as well as creating dependencies between them. Any suggestions?