A provider is an object with a $get() method. The injector calls the $get method to create a new instance of a service. The Provider can have additional methods which would allow for configuration of the provider.
Questions tagged [angularjs-provider]
59 questions
2
votes
2 answers
How do I know what dependencies I can inject into a controller?
I am trying to use $routeProvider dependency inside my controller:
.controller('mainController', function($scope, $state, $routeProvider) {
But I am getting the error:
Error: [$injector:unpr] Unknown provider: $routeProviderProvider <-…

chopper draw lion4
- 12,401
- 13
- 53
- 100
2
votes
2 answers
Why shouldn't I access the factory function through a provider.$get in the config phase?
First of all, this is an honest question. And I'm looking for honest and justified answers on why I shouldn't be doing this...
angular
.module('X', ['Y'])
.config(function (myFactoryProvider, myServiceProvider) {
…

rfgamaral
- 16,546
- 57
- 163
- 275
2
votes
2 answers
Wait for Provider to finish before entering State
I'm trying to wait for the provider to finish initializing before ui-router goes on to load the state.
Every time you enter the state the camera should be enabled, and whenever it is left disabled again. I put this into a provider because it needs…

s-ol
- 1,674
- 17
- 28
2
votes
2 answers
How to create any kind of immutable providers in AngularJS
Consider the following example:
angular.module('demo')
.service('MyService', function () {
this.fn = function () {
console.log('MyService:fn');
};
})
.factory('MyFactory', function () {
function fn()…

rfgamaral
- 16,546
- 57
- 163
- 275
1
vote
0 answers
AngularJs - How to update Internal data within a Factory?
I have a factory in my app which takes environment uri data as input parameter and returns a $resource object as below. The coreService is a singleton object used in many other controllers of UI. Initially, the app gets registered with default…

Sby
- 11
- 2
1
vote
0 answers
Angular JS: Unknown provider: $mdThemingProviderProvider <- $mdThemingProvider
When the High Contrast Mode is on, I need to use the dark theme and is working as below:
$mdThemingProvider.theme('default')
.primaryPalette('green')
.accentPalette('orange', {
'hue-3': 'A700'
…

CodeZila
- 919
- 2
- 14
- 31
1
vote
0 answers
Use service as provider in config but also as service in controller
So I have this service :
var module = angular.module('app.shared.user', []);
module.service('userService', ['$q', '$http', 'firebaseService', function($q, $http, firebaseService) {
this.isAdmin = undefined;
this.userIdToken = undefined;
…

Stéphane Conq
- 38
- 4
1
vote
1 answer
Using $sceProvider functionality from $sce
From Angular documents it says that $sceDelegateProvider.resourceUrlWhitelist can set the trusted resource URLs, But I need that functionality from the controller.
I want to set a whitelist of trusted resource URLs within my service. Therefore, I…

Moris
- 135
- 11
1
vote
1 answer
JavaScript- calling a function defined inside a provider
I have recently taken on the development of web app that has been written in AngularJS. In one of the files, myApp.js, there is a provider that is defined as follows:
.provider('myAppConf', function($routeProvider){
var constants = {
…

Noble-Surfer
- 3,052
- 11
- 73
- 118
1
vote
1 answer
angular provider error - must define $get factory method
This coffee script code is trying to create an angular provider but I get this message: Provider 'ItemsProvider' must define $get factory method.
I have the $get method set. Any idea of what is happening?
'use strict'
app =…

victor sosa
- 899
- 13
- 27
1
vote
1 answer
Angular Js service returns function/object?
As per the angular js docs
service(name, constructor);
name : name
constructor : An injectable class (constructor function) that will be instantiated.
Internally :
{
$get: function() {
return $injector.instantiate(constructor);
}
}
It…

ajaykumar
- 646
- 7
- 17
1
vote
3 answers
which is best practice using $routeProvider or using $stateProvider in angularjs?
I am building small app using angularjs and nodejs and i would like to know what is best use case for $stateprovider and $routeProvider.
Please help

khajaamin
- 856
- 7
- 18
1
vote
0 answers
Using a factory in config
I know the config phase runs before the services are available, but I have a situation where I need to use a myJsonDateTimeService to inject a $httpProvider.defaults.transformResponse like that:
angular.module('myJsonDateTimeInterceptor',…

Max Bündchen
- 1,283
- 17
- 38
1
vote
1 answer
different template url on basis of role angular
I have route configuration like :
.config(['$routeProvider',
function ($routeProvider) {
$routeProvider
.when('/home', {
templateUrl: 'partials/home.html',
…

Agnosco
- 155
- 2
- 11
1
vote
2 answers
Angularjs how to resolve unknown provider error in a directive
I am getting the following error in my meanjs app -
Error: [$injector:unpr] Unknown provider: $scopeProvider <- $scope <- uiJqDirective
http://errors.angularjs.org/1.4.7/$injector/unpr?p0=%24scopeProvider%20%3C-%20%24scope%20%3C-%20uiJqDirective
…

Harshit Laddha
- 2,044
- 8
- 34
- 64