I have seen a number of similar questions but none really gave a simple example. Here's one example of how to do something which is similar to a few other very similar examples:
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
};
});
//factory style, more involved but more sophisticated
myApp.factory('helloWorldFromFactory', function() {
return {
sayHello: function() {
return "Hello, World!"
}
};
});
But both do the same thing. Can someone show me why I would use one or other of the above by making this example show some additional functionality that I could get by using one method instead of the other.