Created
November 17, 2014 12:01
-
-
Save JediMindtrick/8b2532de1a92afa49e83 to your computer and use it in GitHub Desktop.
AngularTheBasics-Service Definition
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
//see this stackoverflow question | |
// http://stackoverflow.com/questions/13762228/confused-about-service-vs-factory/13763886#13763886 | |
app.service('myService', function() { | |
// service is just a constructor function | |
// that will be called with 'new' | |
this.sayHello = function(name) { | |
return "Hi " + name + "!"; | |
}; | |
}); | |
app.factory('myFactory', function() { | |
// factory returns an object | |
// you can run some code before | |
return { | |
sayHello : function(name) { | |
return "Hi " + name + "!"; | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment