I am currently working with angularJS and I have run into an issue.
Following Code is not working when I am switching version of AngularJS
<script>
// Code goes here
angular.module('list', []);
function ListCtrl($scope, $http) {
$http({
method: 'GET',
url: 'json_price_1.json'
}).success(function(data) {
$scope.artists = data.artists; // response data
$scope.albums = [];
angular.forEach(data.artists, function(artist, index) {
angular.forEach(artist.albums, function(album, index){
$scope.albums.push(album);
});
});
});
}
</script>
</head>
<body ng-app="list">
<h3>List of Artists</h3>
<div ng-controller="ListCtrl">
<ul ng-repeat="artist in artists">
<li>{{artist.name}}</li>
</ul>
</div>
<h3>List of Albums</h3>
<div ng-controller="ListCtrl">
<ul ng-repeat="album in albums">
<li>{{album.title}}</li>
</ul>
</div>
</body>
Above code is working fine when I am using the old version of AngularJS
Old Version AngularJS link :
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js"></script>
But it is not working when I am calling New AngularJS
New AngularJS Link :
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
help me to fix this issue.
Json file
{
"version": "1",
"artists": [
{
"name": "artist1name",
"jpeg": "../img/artist/artist1.jpg",
"albums": [
{
"type": "cd",
"title": "titlealbum1",
"subtitle": "subtitlealbum1",
"jpeg": "../img/album1.jpg",
"price": "12.00",
"anystring1": "anystring1album1",
"anystring2": "anystring2album1",
"id": "1"
},
{
"type": "cd",
"title": "titlealbum2",
"subtitle": "subtitlealbum2",
"jpeg": "../img/album2.jpg",
"price": "12.00",
"anystring1": "anystring1album2",
"anystring2": "anystring2album2",
"id": "2"
},
{
"type": "cd",
"title": "titlealbum3",
"subtitle": "subtitlealbum3",
"jpeg": "../img/album3.jpg",
"price": "13.00",
"anystring1": "anystring1album3",
"anystring2": "anystring2album3",
"id": "3"
}
]
},
{
"name": "artist2name",
"jpeg": "../img/artist/artist1.jpg",
"albums": [
{
"type": "cd",
"title": "titlealbum4",
"subtitle": "subtitlealbum1",
"jpeg": "../img/album1.jpg",
"price": "12.00",
"anystring1": "anystring1album1",
"anystring2": "anystring2album1",
"id": "4"
},
{
"type": "cd",
"title": "titlealbum5",
"subtitle": "subtitlealbum2",
"jpeg": "../img/album2.jpg",
"price": "12.00",
"anystring1": "anystring1album2",
"anystring2": "anystring2album2",
"id": "5"
},
{
"type": "cd",
"title": "titlealbum6",
"subtitle": "subtitlealbum3",
"jpeg": "../img/album3.jpg",
"price": "13.00",
"anystring1": "anystring1album3",
"anystring2": "anystring2album3",
"id": "6"
}
]
}
]
}