This is my first post in Stack and I'm new to Angular. I'm working on generating dynamic span tags instead of putting them in HTML. It works fine when I've static HTML code, but it doesn't work when its being called from Angular. Because ng-Directive is getting called before ng-Controller.
Here is the static HTML code
<scroller height="150" width="200" padding="5" ng-model="test">
<span><a href="http://www.google.com" target="_blank"><img src="images/img1.png"/></a><p class="title">img0</p></span>
<span><a href="http://www.google.com" target="_blank"><img src="images/img1.png"/></a><p class="title">img1</p></span>
<span><a href="http://www.google.com" target="_blank"><img src="images/img1.png"/></a><p class="title">img2</p></span>
</scroller>
What I'm trying to do is in the following fashion.
<scroller height="150" width="200" padding="5" ng-model="test">
<div ng-repeat="image in imagesArray">
<span><a href="http://www.google.com" target="_blank"><img ng-src='{{image.img}}'/></a><p class="imgtitle">{{image.title}}</p></span>
</div>
</scroller>
My Controller code
function myCtrl($scope,$http){
$scope.test = 0;
$http.get("data.json")
.then(function(response) {
var data = response.data;
$scope.imagesArray = response.data.imagesArray || [];
console.log($scope.imagesArray);
});
}
Objects would be getting created in the following way.
[Object, Object, Object, Object, Object, Object, Object]
0: Object
img: "images/img1.png"
title: "img1 "
etc ..
Do I need to follow anything else? Any ideas would be greatly appreciated.