-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
50 lines (47 loc) · 1.26 KB
/
index.js
File metadata and controls
50 lines (47 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
let GLOBAL = require('./src/global');
let Q = require('q');
let $http = require('./src/$http');
let $resource = require('./src/$resource');
if (GLOBAL.angular) {
GLOBAL.angular.module('$resource', [])
.provider('$resource', function () {
this.setResponseType = (value)=> {
$resource.responseType = value;
return this;
};
this.setHeaders = (value)=> {
$resource.headers = value;
return this
};
this.setWithCredentials = (value)=> {
$resource.withCredentials = value;
return this;
};
this.setHosts = (value)=> {
$resource.hosts = value;
return this;
};
this.setInterceptor = (func)=> {
$resource.interceptor = func;
return this;
};
this.setTransformHeaders = (func) => {
$resource.transformHeaders.push(func);
return this;
};
this.$get = ['$q', function ($q) {
$http.injector('$q', $q);
$resource.injector('$http', $http);
return $resource;
}]
});
} else {
$http.injector('$q', Q);
$resource.injector('$http', $http);
if (GLOBAL.$ && GLOBAL.jQuery) {
GLOBAL.$.$resource = $resource;
} else {
GLOBAL.$resource = $resource;
}
}
module.exports = $resource;