Plunker:http://plnkr.co/edit/XH8EiFpw1eUVrRtoByeY?p=preview
从角度read property 'entry' of undefined
升级到1.3.x
1.6.x
我已经尝试过定义'条目'因为var entry = {};
也试过依赖注入,但它仍然出错。
以下是代码:
var app = angular.module('plunker', []);
app.controller('SuperCtrl', ['$scope', '$http', function($scope,$http) {
var url = 'https://spreadsheets.google.com/feeds/list/1O7M5gaEGlyE5gkOBARJrxJJMBYiTwz2THVjgbaTx9v8/od6/public/values?alt=json';
var parse = function(entry) {
console.log(entry);
var category = entry.gsx$category.$t;
var description = entry.gsx$description.$t;
var title = entry.gsx$title.$t;
return {
description: description,
title: title
};
};
$http.get(url)
.then(function(response) {
var entries = response.feed.entry;
$scope.parsedEntries = [];
for (var key in entries) {
var content = entries[key];
$scope.parsedEntries.push(parse(content));
}
});
}]);
答案 0 :(得分:0)
在这部分代码中:
$http.get(url)
.then(function(response) {
var entries = response.feed.entry;
...
});
您应该通过响应的data
属性:
$http.get(url)
.then(function(response) {
var entries = response.data.feed.entry;
...
});