Summary

AngularJS custom services are singleton objects that you can register with the dependency injector. After they’re registered with the dependency injector, controllers, directives, and other AngularJS components, including other services, can consume them. AngularJS provides several methods for creating custom services, with varying levels of complexity. The value and constant methods create simple services. On the other hand, the factory and service methods enable you to create much more complex services.

This chapter focused on the tools to enable you to implement your own custom AngularJS services when you need to provide task-based functionality to your applications. You learned about the four methods or types of custom AngularJS services, including value, constant, factory, and service.

This chapter showed examples of implementing each of the types of custom AngularJS services. You also were shown an example of implementing a custom AngularJS service in multiple controllers. The final example in this chapter showed you how to implement a standalone custom AngularJS service that interacts with the server using $http and how to inject and use it in another module.

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

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