aboutsummaryrefslogtreecommitdiffstats
path: root/src/Resource.js
diff options
context:
space:
mode:
authorVojta Jina2011-10-19 10:47:17 -0700
committerIgor Minar2011-11-30 11:17:22 -0500
commitfeacf608eefa8cc64845a643f7270c9c3a16d1b8 (patch)
tree43b13081c41f17b7994577c6cb02e6216f5c5b30 /src/Resource.js
parentfe633dd0cf3d52f84ce73f486bcbd4e1d3058857 (diff)
downloadangular.js-feacf608eefa8cc64845a643f7270c9c3a16d1b8.tar.bz2
fix($resource): to work with $http, $httpBackend services
Breaks Disabling $resource caching for the moment.
Diffstat (limited to 'src/Resource.js')
-rw-r--r--src/Resource.js21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/Resource.js b/src/Resource.js
index 959561e4..4bec60f9 100644
--- a/src/Resource.js
+++ b/src/Resource.js
@@ -36,8 +36,8 @@ Route.prototype = {
}
};
-function ResourceFactory(xhr) {
- this.xhr = xhr;
+function ResourceFactory($http) {
+ this.$http = $http;
}
ResourceFactory.DEFAULT_ACTIONS = {
@@ -107,11 +107,11 @@ ResourceFactory.prototype = {
}
var value = this instanceof Resource ? this : (action.isArray ? [] : new Resource(data));
- self.xhr(
- action.method,
- route.url(extend({}, extractParams(data), action.params || {}, params)),
- data,
- function(status, response) {
+ var future = self.$http({
+ method: action.method,
+ url: route.url(extend({}, extractParams(data), action.params || {}, params)),
+ data: data
+ }).on('success', function(response, status) {
if (response) {
if (action.isArray) {
value.length = 0;
@@ -123,9 +123,10 @@ ResourceFactory.prototype = {
}
}
(success||noop)(value);
- },
- error || action.verifyCache,
- action.verifyCache);
+ });
+
+ if (error) future.on('error', error);
+
return value;
};