JSON文件中的数组未被标识为数组

时间:2015-01-30 16:59:59

标签: javascript arrays json angularjs

我有一个错误导致我精神错乱。基本上我所要做的就是为数组中的每个项重复li。相反,我得到了这个:

ng-repeat error

当我检索JSON时,看起来阵列没有被注意到。相反,它只是将所有内容放在一起以创建一个长逗号分隔的字符串。这是为什么?

当我检索JSON文件时,我将其绑定到范围,如下所示:

$http.get('jsons/' + $routeParams.pieId + '.json')
     .success(function(data) {
        $scope.pie = data;
     });

这里有什么不对吗?为什么JSON没有注意到我的阵列?

这是我获取的JSON:

{
    "name": "Raspberry pie", 
    "imageUrl": "img/raspberrypie.jpg",
    "rating": 5,
    "description": "Sweet and fresh raspberries are topped with a quick raspberry sauce in this tempting summer dessert. Serve chilled with a dollop of whipped cream.",
    "ingredients": ["Water", "raspberries", "cornstarch", "sugar", "lemon", "wheat", "egg", "milk", "butter"],
    "price": 4.89
}

但这就是出现的结果:

{
    "name": "Raspberry pie", 
    "imageUrl": "img/raspberrypie.jpg",
    "rating": 5,
    "description": "Sweet and fresh raspberries are topped with a quick raspberry sauce in this tempting summer dessert. Serve chilled with a dollop of whipped cream.",
    "ingredients": "Water, raspberries, cornstarch, sugar, lemon, wheat, egg, milk, butter",
    "price": 4.89
}

注意ingredients的差异。

0 个答案:

没有答案