diff options
| author | Tobias Bosch | 2013-11-20 16:45:39 -0800 |
|---|---|---|
| committer | Tobias Bosch | 2013-11-21 09:51:02 -0800 |
| commit | f6ecf9a3c9090593faf5fa50586c99a56b51c776 (patch) | |
| tree | 83ea6e02d5ae252c543c62a78198194c62fa2c95 /src/ngResource/resource.js | |
| parent | a4e6d962d78b26f5112d48c4f88c1e6234d0cae7 (diff) | |
| download | angular.js-f6ecf9a3c9090593faf5fa50586c99a56b51c776.tar.bz2 | |
fix($resource): Always return a resource instance when calling class methods on resources.
Previously, calling `MyResource.save(myResourceInstance)`returned
a promise, in contrast to the docs for `$resource`. However,
calling `MyResource.save({name: 'Tobias"})`already correctly
returned a resource instance.
Fixes #4545.
Closes #5061.
Diffstat (limited to 'src/ngResource/resource.js')
| -rw-r--r-- | src/ngResource/resource.js | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/ngResource/resource.js b/src/ngResource/resource.js index d11a4d60..e2499864 100644 --- a/src/ngResource/resource.js +++ b/src/ngResource/resource.js @@ -439,7 +439,7 @@ angular.module('ngResource', ['ng']). } /* jshint +W086 */ /* (purposefully fall through case statements) */ - var isInstanceCall = data instanceof Resource; + var isInstanceCall = this instanceof Resource; var value = isInstanceCall ? data : (action.isArray ? [] : new Resource(data)); var httpConfig = {}; var responseInterceptor = action.interceptor && action.interceptor.response || @@ -522,7 +522,7 @@ angular.module('ngResource', ['ng']). if (isFunction(params)) { error = success; success = params; params = {}; } - var result = Resource[name](params, this, success, error); + var result = Resource[name].call(this, params, this, success, error); return result.$promise || result; }; }); |
