I am creating an ionic mobile Apps project. I want to display a particular div multiple times in a html page. After that, I would like to display images etc. for each of the div.
Here are my codes snippet:
HTML:
<div style="position:absolute; z-index:1; width:100px; height:100px" ng-style="navigationStyleToilet" ng-repeat="o in arr"></div>
controller.js:
for (i = 0; i < categoryInfo.length; i++)
{
$scope.arr.push(i);
var targetImageX = categoryInfo.X;
var targetImageY = categoryInfo.Y;
$scope.navigationStyleToilet[i] = {
"background-image": "url('../img/CurrentLocaton.gif')",
"background-repeat": "no-repeat",
"background-position": targetImageX + " " + targetImageY
}
}
The categoryInfo array looks like this:
var categoryInfo= new Array();
categoryInfo[0] = { X: 2, Y: 5 };
categoryInfo[1] = { X: 5, Y: 5 };
categoryInfo[2] = { X: 9, Y: 9 };
categoryInfo[3] = { X: 15, Y: 15 };
However, it gives me the error "TypeError: Cannot read property 'push' of undefined". Can someone help me please?
$scope.arr
first. – Leo Dec 30 '16 at 9:27