I am trying to read a json file which contains the list of songs and a url to the image
{"songs" : [
{
"SongName" : "Broken Dreams",
"image" : "img/browser.svg"
},
{
"SongName" : "My heart goes on",
"image" : "img/browser.svg"
},
{
"SongName" : "Summer of 69",
"image" : "img/browser.svg"
},
{
"SongName" : "Broken Hearted Girl",
"image" : "img/browser.svg"
},
{
"SongName" : "American idiot",
"image" : "img/browser.svg"
}
]}
but the basic issue is when I use the $http.get(), it reads the json but I am not able to assign it to the angularJS object, here is my angularJS code
var app = angular.module('TheSlideShow', []);
app.controller('mainController', ['$scope', '$http', function($scope, $http){
$scope.test = "this is a test string";
$scope.songList = {};
$http.get("Data/SongList.json", ['$scope']).success(function(List){ $scope.songList = List.songs; console.log("The Length : " + $scope.songList.length);});
for(var i = 0; i< $scope.length; i++)
{
console.log("loop number" + i);
}
}]);
The Length field gives the result as 5 but my for loop does not run even for a single time..