-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservices.js
More file actions
33 lines (29 loc) · 779 Bytes
/
services.js
File metadata and controls
33 lines (29 loc) · 779 Bytes
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
angular.module("services", ["ngResource"]).
service("companyService", function($resource) {
var defaultCallbacks = { success: function() {}, error: function() {}, complete: function() {} };
return {
getBySymbol: function(symbol, cbs) {
cbs = angular.extend({}, defaultCallbacks, cbs);
var query = $resource(
"http://dev.markitondemand.com/Api/Quote/:action",
{ action: "jsonp", callback: "JSON_CALLBACK", symbol: symbol },
{ get: { method: "jsonp" } }
);
query.get(
function(response) {
if (response.Data) {
cbs.success(response.Data);
}
else {
cbs.error("Invalid symbol");
}
cbs.complete();
},
function() {
cbs.error();
cbs.complete();
}
);
}
};
});