registering service using value in angularjs

2
Registering Service using value in AngularJS A service is created by a service factory and service factories are functions which are created by a service provider(constructor function). When instantiating service provider, there must be a property named $get, which holds service factory logic. The $provide provide helping method for registering services with the help of $injector. When we talk about registering a service using value, here value is nothing more than a simple injectable value. The value can be a string, number, array, function, object. The difference between value and constant is, it can not be injected into configuration. It accepts two parameters, that are: name and value. Syntax is: value(name, value); where name is any string and value can be any string, number, object or function. Here I am explaining a short example of implementing value as a service. JS file:

Upload: findnerd

Post on 15-Aug-2015

17 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Registering Service using value in angularJS

Registering Service using value in AngularJS

A service is created by a service factory and service factories are functions which are created by a service provider(constructor function).

When instantiating service provider, there must be a property named $get, which holds service factory logic.

The $provide provide helping method for registering services with the help of $injector.

When we talk about registering a service using value, here value is nothing more than a simple injectable value. The value can be a string, number, array, function, object. The difference between value and constant is, it can not be injected into configuration. It accepts two parameters, that are: name and value. Syntax is:

value(name, value);

where name is any string and value can be any string, number, object or function.

Here I am explaining a short example of implementing value as a service.JS file:

For full Blog about Registering Service using value in angularJS visit FindNerd.

You can ask technology related questions at FindNerd Forum section. Mostly questions asked from the community Java, Androip, PHP and JavaScript forums.