Skip to content

Instantly share code, notes, and snippets.

@faustman
Created August 10, 2013 16:38
Show Gist options
  • Save faustman/6201096 to your computer and use it in GitHub Desktop.
Save faustman/6201096 to your computer and use it in GitHub Desktop.
provider settings
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