This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Inacurracy in $provide.service documentations #12664
Closed
Description
From Documentations:
Register a service constructor, which will be invoked with
new
to create the service instance. This is short for registering a service where its provider's$get
property is the service constructor function that will be used to instantiate the service instance.
I think this is technically wrong, because as stated in Docs, "An Angular service is a singleton object created by a service factory". So service
method is a shorthand for registering a service where its provider's $get
property is a function that returns an instance created by the service constructor, not the constructor itself.
This is exactly inline with the code for $provide.service
:
function service(name, constructor) {
return factory(name, ['$injector', function($injector) {
return $injector.instantiate(constructor);
}]);
}