1.

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;
});

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;
});



Discussion

No Comment Found