angular/angular.js — pull request #4545 by sanyax7 (2013-10-20 18:38:30+00:00)
Title: Fixing possible bug in initialization of value

Hello, I think I found a bug in initialisation of `value` value in `angular-resource.js`.

I tried to fetch a Json array from my Api server and was getting the following error:

```
TypeError: Object # has no method 'push'
```

I compared code from `v1.0.6` (which is working okay) with the code from `v1.2.0-rc.3` and found the following difference:

```Javascript
v1.0.6:
var value = this instanceof Resource ? this : (action.isArray ? [] : new Resource(data));

v1.2.0-rc.3:
var isInstanceCall = data instanceof Resource;
var value = isInstanceCall ? data : (action.isArray ? [] : new Resource(data));
```

And indeed, `data` is the second parameter to the `Resource[name] = function(a1, a2, a3, a4)` which is called from `Resource.prototype['$' + name] = function(params, success, error)` as:

```Javascript
var result = Resource[name](params, this, success, error);
```

So `this` in the scope of `Resource.prototype` will, presumably, be always instance of `Resource` and `var isInstanceCall = data instanceof Resource;` will be always set to true.

I am, most likely, wrong, but the following change fixed my problem. I think it is worth for someone from the team to take a look at what is going in there.