Created
August 10, 2013 16:38
-
-
Save faustman/6201096 to your computer and use it in GitHub Desktop.
provider settings
This file contains 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
angular.module('displify.settings', []) | |
.provider('$settings', function() { | |
// Private variables | |
var account; | |
var client_settings_var = "_dsplfy"; | |
// Private constructor | |
function Settings($log) { | |
this.account = account; | |
this.test = function(){ | |
console.log($log) | |
} | |
return this; | |
} | |
Settings.$inject = ['$log'] | |
// Public API for configuration | |
this.setAccount = function(a) { | |
account = a; | |
}; | |
this.getAccount = function() { | |
return account; | |
} | |
this.getClientSettings = function(){ | |
console.log('get client settings'); | |
var client_settings = window[client_settings_var]; | |
if(!client_settings && client_settings.id) throw new Error('' + client_settings_var + ' client settings id not set.'); | |
this.setAccount(client_settings.id); | |
} | |
this.getClientSettings(); | |
// Method for instantiating | |
this.$get = Settings; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment