Angular 6 – Services, Dependency Injection, Singleton Pattern, @Injectable

Services is a type of category that surrounds by providing features that an app needs. Service is simply a typescript class with a well defined purpose. To increase modularity to your app, Angular distinguishes components from services This is also known as separation of concerns. A components primary job is to interact with template and nothing more. A component mediates between the template and application logic by binding fields, properties and methods to our template. Like a Component, there are certain task that a Component can delegate, such as fetching data from server, validating input data, or sending a data to server. These type of task can be handled by a separate class in our Angular. And that class is called Service

Table of Contents:

Source Code:

https://stackblitz.com/edit/creating-a-service

Also See

Angular Directives, Structural Directives, Attribute Directives and Component Directives

ALSO READ  Angular 6 Fundamentals - Tutorial from Scratch