【发布时间】:2016-02-03 15:39:48
【问题描述】:
我正在使用 angularJS 从文件中获取 JSON 数据。这样做不会让我得到文件中的数据。我的plunker link
HTML
<body ng-controller="MainCtrl">
<div ng-repeat="(key, data) in groupedByFoodName">
<p>{{key}} {{data.length}}</p>
</div>
</body>
控制器
app.controller('MainCtrl', function($scope,$http) {
$http({
method: 'GET',
url: 'list.json'
}).then(function successCallback(response) {
$scope.lists = response.data;
});
$scope.groupedByFoodName= _.groupBy($scope.lists, function (each) { return each.orderfood[0].name });
});
【问题讨论】:
标签: javascript angularjs json http