Creating Providers in AngularJS Modules

AngularJS provides a number of built-in providers for various objects and services. For example, the $window service has a provider that builds the AngularJS service object that enables you to interact with the underlying Window object in JavaScript. In addition to these providers, you can create providers of your own to inject functionality into AngularJS application components.

The Module object provides several helper methods for adding providers as an alternative to using the config() method. These methods are simpler to use and clearer in your code. You can add two types of provider objects to AngularJS modules. Each of these methods accepts two parameters: the name that will be registered with the dependency injector and the provider function that defines how to build the specific object. The following sections describe these methods in more detail.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset