I've been observing various instances of controller and service creation in AngularJS and I'm feeling perplexed. Could someone elucidate the distinctions between these two methods?
app.service('reverseService', function() {
this.reverse = function(name) {
return name.split("").reverse().join("");
};
});
app.factory('reverseService', function() {
return {
reverse : function(name) {
return name.split("").reverse().join("");
}
}
});
Here's an example of a controller:
function ExampleCtrl($scope) {
$scope.data = "some data";
}
app.controller("ExampleCtrl", function($scope) {
$scope.data = "some data";
}