Last active
August 29, 2015 14:05
-
-
Save lucalanca/328a5ae3d8e6f261957d to your computer and use it in GitHub Desktop.
Angular Service
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
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 |
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() { | |
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