javascript - Why does angular $resource add extra objects ($promise, $resolve...) to my data response? -
i return resource url
$resource("http://foo.com/bar.json").get(). $promise.then(function(data){ $scope.result = data}, function(error){ $scope.msg = "error" } );
resource returns
["item1"...."item_n",.....,"$promise", "$resolved", "$get", "$save", "$query", "$remove", "$delete"]
why objects in data set. i'm guessing $promise returns , waits server response. once have server response can server data without promise jargon?
if @ angular source here:
https://github.com/angular/angular.js/blob/master/src/ngresource/resource.js#l505
there tojson method on resource prototype chain accomplish you.
for example:
$resource("http://foo.com/bar.json").get(function(res) { $scope.result = res.tojson(); });
Comments
Post a Comment