I'm trying to understand some basics about angularjs.

Suppose I have a function:

```
function getMyData() {
  //returns some data...
}

```

Why should I register it as a service and not using it directly in a controller?

i.e. why this:

```
mymodule.factory("getMyDataService", function() {
  return getMyData;
};
mymodule.controller("myController", ["$scope", "getMyDataService", function ($scope, getMyDataService) {
  $scope.data = getMyDataService();
}]);

```

instead of this:

```
mymodule.controller("myController", ["$scope", function ($scope) {
  $scope.data = getMyData();
}]);

```