Services are singles. They are created the first time they are needed. Sometimes you need to configure a service before starting it, for example, in the .config part of the application module. Here you are using $routeProvider . After that, you can normally use the service instance (for example, $route ), for example, in the .run block of the application module. Note that with $routeProvider you define routes (configuration) and $route uses configuration-dependent methods.
There are three ways to define services: the simplest uses service , then you can also use factory and if you need complex configuration, you use provider AngularJS: Service versus provider vs factory
source share