Last active
October 14, 2016 19:11
-
-
Save alecklandgraf/8e71c08e3329d7c9d6c0931a5834f567 to your computer and use it in GitHub Desktop.
angular factories vs 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
angular.module('myModule', []) | |
.factory('myModuleFactory', function() { | |
const state = { | |
loaded: false, | |
}; | |
const setLoaded = () => { | |
state.loaded = true; | |
}; | |
return { | |
state, | |
setLoaded, | |
}; | |
}) | |
.service('myModuleService', function() { | |
const state = { | |
loaded: false, | |
}; | |
const setLoaded = () => { | |
state.loaded = true; | |
}; | |
this.state = state; | |
this.setLoaded = setLoaded; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment