$resource throws TypeError when json has both properties and arrays #1044
Description
When using resource on an endpoint which returns json objects of the form:
{
"property1": "value1",
"property2": "value2",
"array1": [ {"p1": "v1"}, {"p2": "v2"} ]
}
The resource class throws an error:
TypeError: Object #<Resource> has no method 'push'
at copy (http://code.angularjs.org/angular-1.0.0rc8.js:557:21)
at new Resource (http://code.angularjs.org/angular-resource-1.0.0rc8.js:323:9)
at http://code.angularjs.org/angular-resource-1.0.0rc8.js:379:32
at forEach (http://code.angularjs.org/angular-1.0.0rc8.js:118:20)
at http://code.angularjs.org/angular-resource-1.0.0rc8.js:378:19
at http://code.angularjs.org/angular-1.0.0rc8.js:6349:59
at http://code.angularjs.org/angular-1.0.0rc8.js:6386:26
at Object.$eval (http://code.angularjs.org/angular-1.0.0rc8.js:7444:28)
at Object.$digest (http://code.angularjs.org/angular-1.0.0rc8.js:7316:25)
at Object.$apply (http://code.angularjs.org/angular-1.0.0rc8.js:7527:22)
This is due to the Resource class not taking into consideration that part of the json can be an array. It assumes that the destination for copy is already an array when in reality its a Resource and then the push call fails.