1. Question:What are services in AngularJS? 

    Answer
    Angular services are substitutable objects that are wired together using dependency injection (DI). You can use services to organize and share code across your app.Angular services are:
    Lazily instantiated – Angular only instantiates a service when an application component depends on it.
    Singletons – Each component dependent on a service gets a reference to the single instance generated by the service factory.

    1. Report
  2. Question:What is service method? 

    Answer
    Using service method, we define a service and then assign method to it. We've also injected an already available service to it.
    mainApp.service('CalcService', function(MathService){
       this.square = function(a) { 
          return MathService.multiply(a,a); 
    	}
    });

    1. Report
  3. Question:What is a service? 

    Answer
    Services are JavaScript functions and are responsible to do specific tasks only. Each service is responsible for a specific task for example, $http is used to make ajax call to get the server data. $route is used to define the routing information and so on. Inbuilt services are always prefixed with $ symbol.

    1. Report
Copyright © 2024. Powered by Intellect Software Ltd