I'd like to know if there is a way of making the configuration of a provider unique not across the entire application, but only across the module that is configuring it.
For example, I have a module "core" which contains the definition of a provider. Then I have modules "module1" and "module2" which use the provider but have to configure it in a particular way for the specific module.
What is happening with me is that the configuration done in the module defined last overrides the configuration done in all other modules that use the provider in the application.
I made this simple plunker to exemplify this:
var app = angular.module('app', ['module1','module2']);
angular.module('core',[])
.provider('movie', function () {
var version;
return {
setVersion: function (value) {
version = value;
},
$get: function () {
return {
title: 'The Matrix' + ' ' + version
}
}
}
});
angular.module('module1',['core'])
.config(function (movieProvider) {
movieProvider.setVersion('Reloaded');
})
.controller('ctrl1', function ($scope,movie) {
$scope.title = movie.title;
$scope.module = 'module1';
});
angular.module('module2',['core'])
.config(function (movieProvider) {
movieProvider.setVersion('Revolutions');
})
.controller('ctrl2', function ($scope,movie) {
$scope.title = movie.title;
$scope.module = 'module2';
});