AngularJS Developer Question:
Download Job Interview Questions and Answers PDF
Explain me 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;
});
var mainApp = angular.module("mainApp", []);
mainApp.factory('MathService', function() {
var factory = {};
factory.multiply = function(a, b) {
return a * b
}
return factory;
});
Download AngularJS Developer Interview Questions And Answers
PDF
Previous Question | Next Question |
Tell me how angular.module works? | Explain on which types of component can we create a custom directive? |