I am facing an issue with my custom provider in AngularJS that is supposed to handle global configurations for my application. Despite my efforts, I am unable to properly inject this provider as AngularJS keeps throwing an "Unknown provider" exception. This problem has left me puzzled and unsure of what could be causing it.
app.js
(function () {
'use strict';
angular.module('app', [
'config'
])
.config(configuration);
configuration.$inject = ['ConfigProvider'];
function configuration(ConfigProvider) {
ConfigProvider.setFoo(86400);
}
})();
config-provider.js
(function () {
'use strict';
angular.module('config')
.provider('ConfigProvider', ConfigProvider);
ConfigProvider.$inject = [];
function ConfigProvider() {
var config = [];
var provider = {
$get: $get,
setFoo: setFoo,
};
return provider;
function $get() {
return {
getConfig: function () {
return config;
}
};
}
function setFoo(foo) {
config['foo'] = foo;
}
}
})();
config-provider.js is being loaded first in my scripts file, however, rearranging the order does not seem to affect the outcome - the "Unknown provider" error persists. Any insights or assistance on resolving this issue would be greatly appreciated.