alexandernst
alexandernst

Reputation: 15089

AngularJS inheritance of 'config' from one module to another

I have two modules, like the following ones:

var a = angular.module('a', []);
a.config(['$interpolateProvider', function($interpolateProvider) {
    $interpolateProvider.startSymbol('<[');
    $interpolateProvider.endSymbol(']>');
}]);

var b = angular.module('b', ['a']);

I'm running some tests, but I can't figure out if the interpolate configuration in a module is being inherited in b module.

Does angular inherit the config of modules into another modules?

Upvotes: 1

Views: 220

Answers (1)

Nick Tomlin
Nick Tomlin

Reputation: 29251

Inheritance isn't the issue here, you are configuring a provider that is used by both modules, and angular is going to apply each config in the order that you register them. From the docs:

When bootstrapping, first Angular applies all constant definitions. Then Angular applies configuration blocks in the same order they were registered.

You can reset the values of $interpolateProvider start and end symbols, but you cannot have both settings in your application since you are modifying the same provider in each config block.

Here's a plunk showing this in action.

Upvotes: 2

Related Questions