我正在尝试在Angular中创建一个$资源,用于发布某个城市中包含事件的JSON字符串。
angular.module('mean.parties').controller('PartyByCityController', ['$scope', '$routeParams', '$location', '$resource',
function($scope, $routeParams, $location, $resource) {
$scope.findByCity = function() {
var testparties = $resource('/c/:city');
testparties.get({
city: 'copenhagen'
}, function(parties) {
$scope.parties = parties;
});
};
}
]);
然后在我看来,我有:
<section data-ng-controller="PartyByCityController" data-ng-init="findByCity()">
<div class='row'>
{{parties}}
</div>
</section>
这会出现以下错误:
TypeError: Object #<Resource> has no method 'push'
当我在Angular之外访问/ c / Copenhagen时,它运行正常。有谁看到这里有什么问题?