I'm new to angular and have run into a scenario where I don't know the best way to setup this code.
I have 2 JSON files:
images.json
{
"imageName": "example.jpg",
"imageTags": ["fun","work","utility"]
"productID": ["item1","item3"]
}
products.json
{
"productID": "item1",
"productName": "Staple Gun",
"productURL": "Staple-Gun.htm"
}
I don't have any code yet, I'm really trying to make sure I build this properly first.
My goal is to pull images based on tags, so I put a filter on the first ng-repeat portion. This portion works well. But I want to be able to link to the products that are in the images. The easiest thing I found was to do a ng-repeat with the productID as a filter, but if I am pulling 50 photos and each photo has 2 items, that is a ton of repeats. It seems to me that this would require a ton of resources. Is this the best way or is there a better way to handle this?
Code example:
<div ng-repeat="photo in photos | filter: 'fun'">
<img ng-src="{{ photo.imageName }}">
<span>Products In This Image</span>
<div ng-repeat="product in products | filter: photo.productID">
<a ng-href="{{ product.productURL }}" title="{{ product.productName }}">{{ product.productName }}</a>
</div>
</div>