Angularjs里获取数据的方式注意事项:
angular.module('admin.services', ['ngResource'])
// GET TASK LIST ACTIVITY
.factory('getTaskService', function($resource) {
return $resource(
'../rest/api.php',
{ method: 'getTask', q: '*' }, // Query parameters
{'query': { method: 'GET' }}
);
})
'query': {method: 'GET', isArray: false }
$resource("../rest/api"}).get(); return an object $resource("../rest/api").query(); return an array
then you must use : ... return $resource('../rest/api.php?method=getTask&q=*).query();
bulletinApp.factory('Post', ['$resource', function($resource) {
return $resource('/posts', {}, {'query': {method: 'GET', isArray: false}});
}]);