How to remove $promise and $resolved from json object

angularjs, javascript

Solution

I'm looking for the same answer, but at this moment I know only this ugly hack:

To write a func like this:

function cleanResponse(resp) {
    return JSON.parse(angular.toJson(resp));
}

and call it in every single query (ugly, yep):

function getSmt() {
    Resource.get({}, function (data) {
        $scope.some = cleanResponse(data);
    }, function (responce) {
        //handle error
    })
}

I'll be happy if someone would teach me how to do it correctly

Problem

I'm using $resource in angular to get json object and its structure is defined below ``` [ { "id": 0, "name": "Type1" }, { "id": 1, "name": "Type 2" } ] ``` after fetching the data .. console.log(jsonObject) gives me ``` [Resource, Resource, $promise: Object, $resolved: true] ``` How can I remove $promise & $resolved from the resulting object ? I tried angular.fromJson(json) but still I see that these objects still exist.

Original source

Related problems