Services
Syntax:
Result: When declaring serviceName as an injectable argument you will be provided with an instance of the function. In other words
module.service( 'serviceName', function );
Result: When declaring serviceName as an injectable argument you will be provided with an instance of the function. In other words
new FunctionYouPassedToService()
.Factories
Syntax:
Result: When declaring factoryName as an injectable argument you will be provided with the value that is returned by invoking the function reference passed to module.factory.
module.factory( 'factoryName', function );
Result: When declaring factoryName as an injectable argument you will be provided with the value that is returned by invoking the function reference passed to module.factory.
Providers
Syntax:
Result: When declaring providerName as an injectable argument you will be provided with
module.provider( 'providerName', function );
Result: When declaring providerName as an injectable argument you will be provided with
ProviderFunction().$get()
. The constructor function is instantiated before the $get method is called - ProviderFunction is the function reference passed to module.provider.
Providers have the advantage that they can be configured during the module configuration phase.
See Example : http://jsbin.com/ohamub/1/edit
No comments:
Post a Comment