Use Angular.module (). Factory (' Xxxservice ', function () {}) to create the service.
The 2nd parameter of factory (' Xxxservice ', function () {}) or factory (' Xxxservice ', []) can be a function or an array function.
All Service Factory Factory () are created by the $provide service, $provide services are responsible for initializing these services.
All methods of creating a service are built on top of the provider method. The provider () method is responsible for registering the service in the $providercache.
Provider form:
Angular.module (' myApp ') . Factory (' MyService ', function () { return { ' username ': ' Auser '};}) This is equivalent to the usage of the above factory . Provider (' MyService ', { $get: function () { return { ' username ': ' Auser ' };}});
The provider () method returns the extended configuration of the service that is out of scale
ANGULARJS Learning: Services