AngularJS Developer Question:
Download Questions PDF

Tell me what is the role of services in AngularJS and name any services made available by default?


– AngularJS Services are objects that provide separation of concerns to an AngularJS app.
– AngularJS Services can be created using a factory method or a service method.
– Services are singleton components. All components of the application (into which the service is injected) will work with single instance of the service.
– An AngularJS service allows developing of business logic without depending on the View logic which will work with it.

Few of the inbuilt services in AngularJS are:
☛ the $http service: The $http service is a core Angular service that facilitates communication with the remote HTTP servers via the browser’s XMLHttpRequest object or via JSONP
☛ the $log service: Simple service for logging. Default implementation safely writes the message into the browser’s console
☛ the $anchorScroll: it scrolls to the element related to the specified hash or (if omitted) to the current value of $location.hash()
☛ Why should one know about AngularJS Services, you may ask. Well, understanding the purpose of AngularJS Services helps bring modularity to AngularJS code.
☛ Services are the best may to evolve reusable API within and AngularJS app

Download AngularJS Developer Interview Questions And Answers PDF

Previous QuestionNext Question
Tell me when a scope is terminated, two similar “destroy” events are fired. What are they used for, and why are there two?Explain me what is data binding in AngularJS? How does it relate to the MVC architecture?