1. Question:What is factory method? 

    Answer
    Using factory method, we first define a factory and then assign method to it.
    var mainApp = angular.module("mainApp", []);
    mainApp.factory('MathService', function() {     
       var factory = {};  
    		
       factory.multiply = function(a, b) {
          return a * b 
       }
       return factory;
    });

    1. Report
  2. Question:What are the differences between service and factory methods? 

    Answer
    factory method is used to define a factory which can later be used to create services as and when required whereas service method is used to create a service whose purpose is to do some defined task.

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