1

I'm using AngularJS and Django together, so I apply the recipe found here to reconfigure Angular's template delimiters:

angular.module("some module name").config(function($interpolateProvider) {
  $interpolateProvider.startSymbol('{[{');
  $interpolateProvider.endSymbol('}]}');
});

I have to re-apply this piece to each module, only changing the "some module name" string. Is there a way to define this piece of configuration once, and then cleanly require and inject it into a module at the module's definition site?

Community
  • 1
  • 1
9000
  • 39,899
  • 9
  • 66
  • 104
  • Isn't `$interpolateProvider` a provider? That should mean you only need to do it once in your primary module config... – Matt Way Sep 18 '14 at 22:23
  • @MattWay: I have several independent modules. Do you propose to create another module, apply the config to it, and make the target modules require that configured module? I'm new to Angular; I's appreciate an example. – 9000 Sep 18 '14 at 22:39

1 Answers1

2

Since $interpolateProvider is a provider, any change to it will affect not only the current module but also all the modules that depends on it.

You can, for example, define a "config" module and add it as dependency to other modules:

angular.module('config', []).config(function($interpolateProvider) {
  $interpolateProvider.startSymbol('{[{');
  $interpolateProvider.endSymbol('}]}');
});

And on the other modules:

angular.module('module1', ['config']);
angular.module('module2', ['config']);

Demo plunker

bmleite
  • 26,850
  • 4
  • 71
  • 46