我正在尝试使用ng-resource
中的angularjs
从API查询模块列表。
配置,
var classifiedApp = angular.module('classifiedApp', ['ngRoute', 'ngResource']);
服务,
classifiedApp.factory('Module', ['$resource', function ($resource) {
return $resource('api/0.1.0/modules/:id'); // Note the full endpoint address
}]);
在控制器中,
Module.query(function (response) {
$scope.modules = response;
console.info($scope.modules)
});
API返回正确的JSON对象,但在$scope.modules
中包含以下josn,
[Resource { id=1, title="Mobiles & Tablets", categories=[3], more...}, Resource { id=2, title="Vehicles", categories=[7], more...}, Resource { id=3, title="Electronics & Computers", categories=[0], more...}]
如何获得纯API响应JSON
?