Created
July 6, 2012 19:41
-
-
Save dylanz/3062339 to your computer and use it in GitHub Desktop.
Angular $resource
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$http({ | |
method: action.method, | |
url: route.url(extend({}, extractParams(data), action.params || {}, params)), | |
data: data | |
}).then(function(response) { | |
var data = response.data; | |
//**** | |
// I can get the status code here from response.status | |
//**** | |
if (data) { | |
if (action.isArray) { | |
value.length = 0; | |
forEach(data, function(item) { | |
value.push(new Resource(item)); | |
}); | |
} else { | |
copy(data, value); | |
} | |
} | |
(success||noop)(value, response.headers); | |
}, error); | |
return value; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment