这里是我的json-如何从angularJS中的对象数组中获取数据?
{
topalbums: {
album: [
{
name: "The Very Best of Cher",
playcount: 1634402,
mbid: "a7e2dad7-e733-4bee-9db1-b31e3183eaf5",
url: "http://www.last.fm/music/Cher/The+Very+Best+of+Cher",
artist: {
name: "Cher",
mbid: "bfcc6d75-a6a5-4bc6-8282-47aec8531818",
url: "http://www.last.fm/music/Cher"
}
}
]
}
}
如何获取数据,通过循环,采用了棱角分明的控制,每即将到来的对象artist.name?
是的,你需要遍历对象为'album'是对象 – Satpal
在控制器的阵列,如何循环? –
$ scope.data = topTracksService.list; $ scope.tracks = $ scope.data.track; console.log($ scope.tracks); angular.forEach($ scope.tracks,function(value,key){});以上代码不起作用 –