Accessing nested JSON with AngularJS

后端 未结 4 1360
谎友^
谎友^ 2020-12-05 01:08

I\'m trying to make and mobile webapp with angular.js, hammer.js and topcoat.

I\'m having some trouble on displaying data from a Json file like this one:

<         


        
4条回答
  •  再見小時候
    2020-12-05 01:37

    I suggest something like this:

    $http({method: 'GET', url: 'json/json_price_1.json'}).success(function(data) {
        $scope.artists = [];
        angular.forEach(data.artists, function(value, key) {
            $scope.artists.push(value);
        });
        $scope.isVisible = function(name){
            return true;// return false to hide this artist's albums
        };
    });
    

    And then:

    • {{artist.name}}
    • {{album.title}}

提交回复
热议问题