-
Notifications
You must be signed in to change notification settings - Fork 3
Services
Jesper Lindström edited this page Jun 8, 2014
·
1 revision
Services are simply data providers or managers. Instead of calling the API server directly from your controller or library, you should call the API via a service. Your controllers and libraries may use data from the API, but they should not take care of how to obtain it – that's for the service.
Services are located in app/services/*.js and must be added to the autoload part of config.js to be loaded. Controllers would be able to access the following service's method via app.services.myService.getData(function(data) { ... }).
app.services.myService = function() {
this.getData = function(callback) {
app.core.api.get('/get/data', callback);
};
};