AngularJS Developer Question:
Download Questions PDF

Explain me what is provider?


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;


Download AngularJS Developer Interview Questions And Answers PDF

Previous QuestionNext Question
Explain me what are the basic steps to unit test an AngularJS filter?What is ng-show directive?