diff --git a/src/ngResource/resource.js b/src/ngResource/resource.js index ce3468794094..5114c1efe0ee 100644 --- a/src/ngResource/resource.js +++ b/src/ngResource/resource.js @@ -536,8 +536,14 @@ angular.module('ngResource', ['ng']). } /* jshint +W086 */ /* (purposefully fall through case statements) */ - var isInstanceCall = this instanceof Resource; - var value = isInstanceCall ? data : (action.isArray ? [] : new Resource(data)); + var isInstanceCall = this instanceof Resource, value; + + if (action.isArray) { + value = []; + } else { + value = isInstanceCall ? data : new Resource(data); + } + var httpConfig = {}; var responseInterceptor = action.interceptor && action.interceptor.response || defaultResponseInterceptor; @@ -597,6 +603,9 @@ angular.module('ngResource', ['ng']). promise = promise.then( function (response) { var value = responseInterceptor(response); + if(action.saveAs){ + data[action.saveAs] = value; + } (success || noop)(value, response.headers); return value; },