I have a unique HTML challenge that requires me to iterate through an unconventional data setup. The information is retrieved in two separate parts from Firebase: one for categories
and another for businesses
. The structure of the data is as follows:
Businesses
-UniqueFirebaseID
cat: "food"
Categories
-IniqueFirebaseID
name: "food"
My goal is to loop through the data using the following approach (apologies for the lack of semantic markup):
<ul>
<li v-for="cat in categories">
<ul>
<li v-for="business in filteredByCat">{{business.name}}</li>
</ul>
</li>
</ul>
I am currently attempting to create a computed property for filtering purposes. Although I have outlined my intentions below, I am unsure about the implementation. Any recommendations?
computed: {
filteredByCat () {
return this.businesses.filter((element) => {
return element.cat.match(cat.name)
})
}
}