Angular Essentials: Step-by-Step Guidance With Code Examples by Infragistics Publishing & Rabi Kiran & Mahesh Sabnis & Suprotim Agarwal

Angular Essentials: Step-by-Step Guidance With Code Examples by Infragistics Publishing & Rabi Kiran & Mahesh Sabnis & Suprotim Agarwal

Author:Infragistics Publishing & Rabi Kiran & Mahesh Sabnis & Suprotim Agarwal [Publishing, Infragistics]
Language: eng
Format: epub
Publisher: Infragistics, Inc.
Published: 2017-03-24T07:00:00+00:00


Listing 27.10: A factory function returning an object of DataService

Listing 27.11 specifies this method in the providers option.

Listing 27.11: providers using useFactory

Conclusion

This chapter demonstrated how Services can be registered in different ways in Angular 2 and how their objects can be controlled using different options available in the provider registration. These features make the DI system in Angular extremely powerful and flexible. Some of these features help in mocking services in unit tests as well. We will cover these features in the chapters on unit testing.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.