O'Reilly logo

Angular Test-Driven Development - Second Edition by Md. Ziaul Haq

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Angular services

Angular services were introduced to write code shareable among components. So if we need a piece of code for many components, it's recommended to create a single reusable service, and wherever we need that piece of code, we can just inject that service to the component and use its methods as needed.

Services are used to abstract application logic. They are used to provide a single responsibility for a particular action. Single responsibility allows components to 
be easily tested and changed. This is because the focus is on one component and 
not all the inner dependencies.

Mostly, a service acts as the data source of any application. Whenever we need a piece of code to communicate with the server to get data (mostly JSON), we use ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required