1. Question:What is Routing in AngularJS? 

    Answer
    AngularJS Routing helps you to divide your app into multiple views and bind different views to Controllers. The magic of Routing is taken care by an AngularJS service $routeProvider. $routeProvider service provides method when() and otherwise() to define the routes for your app. Routing has dependency on ngRoute module.






    1. Report
  2. Question:Define $http service in AngularJS. 

    Answer
    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.






    1. Report
  3. Question:What is Scope? 

    Answer
    Scope is an object that refers to the application model. It is an execution context for expressions. Scopes are arranged in hierarchical structure which mimic the DOM structure of the application. Scopes can watch expressions and propagate events.






    1. Report
  4. 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
  5. Question:What is provider? 

    Answer
    provider is used by AngularJS internally to create services, factory etc. during config phase(phase during which AngularJS bootstraps itself). Below mention script can be used to create MathService that we've created earlier. Provider is a special factory method with a method get() which is used to return the value/service/factory.
    //define a module
    var mainApp = angular.module("mainApp", []);
    ...
    //create a service using provider which defines a method square to return square of a number.
    mainApp.config(function($provide) {
       $provide.provider('MathService', function() {
    	
          this.$get = function() {
             var factory = {};  
             factory.multiply = function(a, b) {
                return a * b; 
             }
             return factory;
          };
    		
       });
    });






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