Skip to content

Instantly share code, notes, and snippets.

@antoniocapelo
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antoniocapelo/8f54d80b1f0fcae77945 to your computer and use it in GitHub Desktop.
Save antoniocapelo/8f54d80b1f0fcae77945 to your computer and use it in GitHub Desktop.
Service Creation in AngularJS
var app = angular.module('capeloMod', []);
app.service('demoService', function() {
this.publicValue = 0;
var privateValue = 0;
var privateFn = function() {
return 1 + 2;
};
this.apiFn = function(arg) {
return this.publicValue++;
};
this.apiFn2 = function() {
return privateFn () + privateValue++;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment