Okay, I checked it out, I read it and applied it to my code. colleciton-repeat
directive doesn’t seem to work with ion-item
because it doesn’t render anything when I changed from ng-repeat
to collection-repeat
I’ve also noticed that colleciton-item-width
and collection-item-height
doesn’t work with ng-repeat
However, I didn’t find them to be a big problem until I used a div
inside ion-content
(replacing all the ion-list
and ion-item
so I could use collection-repeat
with colleciton-item-width
and collection-item-height
). It seems that collection-repeat
repeats items 25 times even when there are only 5 objects in an array. See this screenshot of Firefox’s Firebug:
The data shows correctly (all 5 items) when using ng-repeat
in the div
but collection-item-width
and collection-item-height
doesn’t work.
Going back to just using collection-repeat
in a div
like this:
<ion-content>
<div class="item my-image-item"
collection-repeat="recipe in recipes"
collection-item-width="'25%'"
collection-item-height="'25%'">
<img ng-src="{{ recipe.feature_img }}">
<h2>{{ recipe.name }}</h2>
</div>
</ion-content>
This is the factory service:
.factory('RecipesFactory', function() {
var Recipes = {};
Recipes.data = [{
id: 1,
name: "Stuffed Omelet",
feature_img: './img/Photo Apr 08, 9 19 48 AM.png',
}, {
id: 2,
name: "Snoopy Rice Ball",
feature_img: "./img/Photo Apr 21, 11 00 11 AM.png",
},{
id: 3,
name: "Tofu Salad",
feature_img: "./img/Photo Apr 30, 10 54 44 AM.png",
},{
id: 4,
name: "Airplane Cookie",
feature_img: "./img/Photo Mar 10, 9 24 31 AM.png",
},{
id: 5,
name: "Panda Rice Balls",
feature_img: "./img/Photo Mar 03, 1 02 10 PM.png",
}];
Recipes.GetAllRecipes = function() {
return Recipes.data;
};
})
Controller:
$scope.recipes = RecipesFactory.GetAllRecipes();
The items overlap each other. And this grid doesn’t show itself to be responsive.
See this screenshot:
Maybe I’m just not getting it but I did really try and followed the documentation. But I can’t find what I’m doing wrong or there’s probably a bug.