@@ -2218,12 +2218,11 @@ function processResults(utils, data, resourceName, queryHash) {
22182218 delete resource . pendingQueries [ queryHash ] ;
22192219 resource . completedQueries [ queryHash ] = new Date ( ) . getTime ( ) ;
22202220
2221- // Merge the new values into the cache
2222- this . inject ( resourceName , data ) ;
2223-
22242221 // Update modified timestamp of collection
22252222 resource . collectionModified = utils . updateTimestamp ( resource . collectionModified ) ;
2226- return data ;
2223+
2224+ // Merge the new values into the cache
2225+ return this . inject ( resourceName , data ) ;
22272226}
22282227
22292228function _findAll ( utils , resourceName , params , options ) {
@@ -4479,9 +4478,11 @@ function _inject(definition, resource, attrs) {
44794478 }
44804479 }
44814480
4481+ var injected ;
44824482 if ( _this . utils . isArray ( attrs ) ) {
4483+ injected = [ ] ;
44834484 for ( var i = 0 ; i < attrs . length ; i ++ ) {
4484- _inject . call ( _this , definition , resource , attrs [ i ] ) ;
4485+ injected . push ( _inject . call ( _this , definition , resource , attrs [ i ] ) ) ;
44854486 }
44864487 } else {
44874488 if ( ! ( definition . idAttribute in attrs ) ) {
@@ -4526,12 +4527,14 @@ function _inject(definition, resource, attrs) {
45264527 }
45274528 resource . saved [ id ] = _this . utils . updateTimestamp ( resource . saved [ id ] ) ;
45284529 definition . afterInject ( definition . name , item ) ;
4530+ injected = item ;
45294531 } catch ( err ) {
45304532 $log . error ( err ) ;
45314533 $log . error ( 'inject failed!' , definition . name , attrs ) ;
45324534 }
45334535 }
45344536 }
4537+ return injected ;
45354538}
45364539
45374540/**
@@ -4595,18 +4598,15 @@ function inject(resourceName, attrs, options) {
45954598 _this = this ;
45964599
45974600 try {
4601+ var injected ;
45984602 if ( ! this . $rootScope . $$phase ) {
45994603 this . $rootScope . $apply ( function ( ) {
4600- _inject . apply ( _this , [ definition , resource , attrs ] ) ;
4604+ injected = _inject . apply ( _this , [ definition , resource , attrs ] ) ;
46014605 } ) ;
46024606 } else {
4603- _inject . apply ( _this , [ definition , resource , attrs ] ) ;
4604- }
4605- if ( _this . utils . isArray ( attrs ) ) {
4606- return attrs ;
4607- } else {
4608- return this . get ( resourceName , attrs [ definition . idAttribute ] ) ;
4607+ injected = _inject . apply ( _this , [ definition , resource , attrs ] ) ;
46094608 }
4609+ return injected ;
46104610 } catch ( err ) {
46114611 if ( ! ( err instanceof this . errors . RuntimeError ) ) {
46124612 throw new this . errors . UnhandledError ( err ) ;
0 commit comments