Created
September 13, 2014 10:12
-
-
Save antoniocapelo/ff09216c153cf898b622 to your computer and use it in GitHub Desktop.
Factory creation in AngularJS
This file contains hidden or 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
var app = angular.module('capeloMod', []); | |
//factory style, more involved but more sophisticated | |
app.factory('demoFactory', function() { | |
var publicValue = 0; | |
var privateValue = 0; | |
function apiFn() { | |
return this.publicValue++; | |
} | |
function apiFn2() { | |
return privateValue++; | |
} | |
return { | |
apiFn : apiFn, | |
apiFn2 : apiFn2, | |
publicValue : publiValue | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment