Answer the question
In order to leave comments, you need to log in
In what format to pass json to Angular?
Please help:
Understanding Angular, ng-table.
Here is a request
var Api = $resource("/data.txt", false);
this.tableParams = new NgTableParams({}, {
getData: function (params) {
return Api.get(params.url()).$promise.then(function (data) {
params.total(data.inlineCount); // recal. page nav controls
return data.results;
});
}
});
[{ "name": "christian", "age": 21 }, { "name": "anthony", "age": 88 }, { "name": "gfgfgfgf", "age": 8 }]
angular.js:12332 Error: [$resource:badcfg] Error in resource configuration for action `get`. Expected response to contain an object but got an array (Request: GET /data.txt)
Answer the question
In order to leave comments, you need to log in
This is not a bug - that's how ngResource is designed.
It's easier for you to use $http.get if you don't need to communicate with REST. Here is an excerpt from the standard methods documentation:
A resource "class" object with methods for the default set of resource
actions optionally extended with custom actions.
The default set contains these actions:
{ 'get': {method:'GET'},
'save': {method:'POST'},
'query': {method:'GET', isArray:true},
'remove': {method:'DELETE'},
'delete': {method:'DELETE'} };
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question