auto.$provide.service()

service(name, constructor);

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 a factory function that returns an instance instantiated by the injector from the service constructor function.

Internally it looks a bit like this:

{
  $get: function() {
    return $injector.instantiate(constructor);
  }
}

You should use $provide.service(class) if you define your service as a type/class.

Parameters

Param Type Details
name string

The name of the instance.

constructor function()Array.<(string|function())>

An injectable class (constructor function) that will be instantiated.

Returns

Object

registered provider instance

doc_AngularJS
2016-03-29 16:11:04
Comments
Leave a Comment

Please login to continue.