Welcome Guest! (App Version 5.16)

websitnero logo name


Services in Angular

'Services' are basically used to implement the DRY concept (Do Not Repeat Yourself) in JavaScript. Whatever you think gets repeated in all components and writign same code multiple times, it is suggested that you keep that code at one place in a service as function -- and then call that function everytime wherever you need from any component or other place.

For example, you need to get data to 3 components, then why write code to make API call at 3 places. Its better to write code as a function once in a service, and call that service from 3 components to get data whenever needed.

It is much better code writing method and also if any change required in implementatino of service-hit, you'll need to make change at only one single place than making change at 3 different places.

WebsiteNero is highly optimized for learning various website developing technlogies. We try our best to add maximum modules and examples to help learn the concepts clearly and vividly. We try to present all content and examples as simple as we can removing any complexity to hurdle easy understanding. We try best provide you with worthful content, but we cannot guarantee full correctness of all the content on this site. While using this website, you agree to have read and accepted all our terms of use and conditions, cookie, and privacy policy. Copyright, 2013-2018 by websitenero.com. All Rights Reserved.