Created
June 6, 2013 12:34
-
-
Save webhat/5721162 to your computer and use it in GitHub Desktop.
Keen.IO Resource Factory with Service Model
This file contains hidden or 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
'use strict'; | |
angular.module('keeniolab', ['ngResource']). | |
factory('KeenIO',function ($resource) { | |
var KeenIO = $resource('https://api.keen.io/3.0/projects/513a76812975164a4a000002/queries/:type', | |
{ | |
api_key: 'api-key', | |
event_collection: 'read', | |
timezone: 7200 | |
}, { | |
update: { method: 'PUT' } | |
} | |
); | |
return KeenIO; | |
}).service('KeenModel', function (KeenIO) { | |
var KeenSession = function () { | |
this.data = {}; | |
}; | |
KeenSession.prototype.fetch = function (query) { | |
var self = this; | |
KeenIO.get(query, function (result) { | |
//console.log("called get"); | |
self.data = result; | |
//console.log(result.result); | |
}); | |
}; | |
return new KeenSession(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment