Created
October 21, 2019 11:23
-
-
Save tonyjoanes/924ec81d04303921fa0afe83d29d0181 to your computer and use it in GitHub Desktop.
AngularJS Services
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
(function () { | |
'use strict'; | |
var serviceId = 'myService'; | |
angular.module('app', serviceId); | |
myService.$inject = ['dependencyOne', 'dependencyTwo']; | |
function myService( | |
dependencyOne, | |
dependencyTwo | |
) { | |
var privateVariable = 15156; | |
var api = { | |
myFunction: myFunction | |
} | |
return api; | |
function myFunction() { | |
// do some cool stuff in here | |
} | |
///////////////////////////////////////// | |
// private functions can go below here // | |
///////////////////////////////////////// | |
function privateFunction(val1, val2) { | |
return privateVariable * (val1 + val2); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment