Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

$resource.query turn strings into objects in response array #6314

Closed
@ya-betmen

Description

@ya-betmen

http://plnkr.co/edit/6Up7bFGica8qOYTs3Gwk?p=preview

bug.html

<html ng-app="demo">
    <head>
        <title></title>
        <meta content="">
        <style></style>
        <script type="text/javascript" src="1.2.9/angular.js"></script>
        <script type="text/javascript" src="1.2.9/angular-resource.js"></script>
        <script type="text/javascript">
            angular.module('demo', ['ngResource'])
                    .controller('MainCtrl', function($scope, $resource) {
                        $resource('http://localhost/array.json', {}, {}).query(function(data) {
                            $scope.test = data;
                        });
                    });
        </script>
    </head>
    <body ng-controller="MainCtrl">
        {{test}}
    </body>
</html>

array.json

[{
        "@class": "class1",
        "@id": "31fde5d2-bad3-4dbf-892d-ae20323db310",
        "id": 1,
        "array": [
            {
                "@class": "class1",
                "@id": "8889b00c-b14d-47a8-9d82-ae3ca5d4b2d0",
                "id": 2

            }, {
                "@class": "class1",
                "@id": "100fe202-16b3-4e39-990e-a4f6c5005341",
                "id": 3
            }, {
                "@class": "class1",
                "@id": "fc2a83f4-27be-46b0-acd3-6a0430025af1",
                "id": 4
            }, {
                "@class": "class1",
                "@id": "c3d6630f-93b4-40b6-a37b-e0ce2b69dff3",
                "id": 5
            }
        ]
}, "8889b00c-b14d-47a8-9d82-ae3ca5d4b2d0", "100fe202-16b3-4e39-990e-a4f6c5005341", "fc2a83f4-27be-46b0-acd3-6a0430025af1", "c3d6630f-93b4-40b6-a37b-e0ce2b69dff3"]

result

[{"@class":"class1","@id":"31fde5d2-bad3-4dbf-892d-ae20323db310","id":1,"array":[{"@class":"class1","@id":"8889b00c-b14d-47a8-9d82-ae3ca5d4b2d0","id":2},{"@class":"class1","@id":"100fe202-16b3-4e39-990e-a4f6c5005341","id":3},{"@class":"class1","@id":"fc2a83f4-27be-46b0-acd3-6a0430025af1","id":4},{"@class":"class1","@id":"c3d6630f-93b4-40b6-a37b-e0ce2b69dff3","id":5}]},{"0":"8","1":"8","2":"8","3":"9","4":"b","5":"0","6":"0","7":"c","8":"-","9":"b","10":"1","11":"4","12":"d","13":"-","14":"4","15":"7","16":"a","17":"8","18":"-","19":"9","20":"d","21":"8","22":"2","23":"-","24":"a","25":"e","26":"3","27":"c","28":"a","29":"5","30":"d","31":"4","32":"b","33":"2","34":"d","35":"0"},{"0":"1","1":"0","2":"0","3":"f","4":"e","5":"2","6":"0","7":"2","8":"-","9":"1","10":"6","11":"b","12":"3","13":"-","14":"4","15":"e","16":"3","17":"9","18":"-","19":"9","20":"9","21":"0","22":"e","23":"-","24":"a","25":"4","26":"f","27":"6","28":"c","29":"5","30":"0","31":"0","32":"5","33":"3","34":"4","35":"1"},{"0":"f","1":"c","2":"2","3":"a","4":"8","5":"3","6":"f","7":"4","8":"-","9":"2","10":"7","11":"b","12":"e","13":"-","14":"4","15":"6","16":"b","17":"0","18":"-","19":"a","20":"c","21":"d","22":"3","23":"-","24":"6","25":"a","26":"0","27":"4","28":"3","29":"0","30":"0","31":"2","32":"5","33":"a","34":"f","35":"1"},{"0":"c","1":"3","2":"d","3":"6","4":"6","5":"3","6":"0","7":"f","8":"-","9":"9","10":"3","11":"b","12":"4","13":"-","14":"4","15":"0","16":"b","17":"6","18":"-","19":"a","20":"3","21":"7","22":"b","23":"-","24":"e","25":"0","26":"c","27":"e","28":"2","29":"b","30":"6","31":"9","32":"d","33":"f","34":"f","35":"3"}]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions