= EdenMobile Services = [[TOC]] Services in EdenMobile are singleton objects providing access to global data and functionality. == Services Overview == ||='''Name'''=||='''Functionality'''=|| ||[wiki:DeveloperGuidelines/EdenMobile/Services/emDB emDB]||Low-level Database Access (tables)|| ||emDialogs||Generic !Popup/Popover User Dialogs|| ||emConfig||Global Configuration Settings|| ||emFiles||Uploaded Files|| ||emForms||Introspective Form Building|| ||emResources||High-level Database Access (resources)|| ||emS3JSON||S3JSON codec|| ||emServer||Sahana Server Access|| ||emSQL||SQL Construction (SQLite)|| ||emSync||Synchronization with Sahana Server|| ||emUtils||Utility Functions|| ||[wiki:DeveloperGuidelines/EdenMobile/Services/emReset emReset]||Database Reset|| == Accessing Services == To access a service in a controller/service/directive/filter, it must be '''injected'''. To do this, the service can be added to the '''dependency list''' in the declaration: {{{#!js EdenMobile.controller('EMSomeController', [ '$scope', '$state', '$stateParams', 'emDialogs', // <== depenency list function($scope, $state, $stateParams, emDialogs) { // <== injected dependencies become parameters // Accessing the service: emDialogs.confirmation(...); }); }}} ...or it can be '''dynamically injected''' (e.g. to avoid circular dependencies), using the {{{$injector}}} service: {{{#!js EdenMobile.factory('emSomeService', [ '$injector', // <== $injector in dependency list function ($injector) { // <== $injector as parameter // Dynamically inject, then access the service var emDialogs = $injector.get('emDialogs'); emDialogs.confirmation(...); }); }}}