Skip to content

Instantly share code, notes, and snippets.

@lucalanca
Last active August 29, 2015 14:05
Show Gist options
  • Save lucalanca/328a5ae3d8e6f261957d to your computer and use it in GitHub Desktop.
Save lucalanca/328a5ae3d8e6f261957d to your computer and use it in GitHub Desktop.
Angular Service
do ->
angular
.module('app')
.factory('Foo', Foo)
Foo = (foo, bar) ->
# Variables (all should be private)
hello = "hello"
world = "world"
# Public Methods
doThis = ->
log "#{hello} #{world}"
isThat = ->
return _maybe || true
# Private Methods
_maybe = ->
return false
# Just return an object with the service api
return {
doThis: doThis
isThat: isThat
}
return
(function() {
var Foo;
angular
.module('app')
.factory('Foo', Foo);
Foo = function(foo, bar) {
// Variables (all should be private)
var hello = "hello"
, world = "world"
;
// Public Methods
function doThis () {
return log("" + hello + " " + world);
};
function isThat () {
return _maybe || true;
}
// Private Methods
function _maybe () {
return false;
};
// Just return an object with the service api
return {
doThis: doThis,
isThat: isThat
};
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment