Whenever we want to use service with the above components, we will have to inject the service name along with the component. By doing so, component ask angular to load that particular service in the application. This method of injecting service is called dependency injection.
To know more about the complete collection of Service lists, please visit Complete lists of Services.
To use a service, you will have to add it as a dependency with a component such as controller, filter or service. To add a service with component, you have to pass it as an argument.
App.controller(“controllerName”, function($scope, $service))
In the above example we injected our $service along with the controller.
There are 2 types of Services are available in AngulrJS,
- Inbuilt Service
- Custom Service
To view the complete information about Service and Factory in AngularJS, Please visit our Blog.