How to reference values with the same name from different modules

后端 未结 2 1398
别那么骄傲
别那么骄傲 2021-02-13 16:05

If I have some modules which defines the same value object:

var m1 = angular.module(\'m1\', []);
m1.value(\'test\', \'AAA\');

var m2 = angular.modu         


        
2条回答
  •  花落未央
    2021-02-13 16:47

    In short - no. AngularJS modules form one namespace. If you define 2 values with the same name on 2 different modules only one will be visible during runtime. This applies to any providers, not only values.

    This might get addressed in future versions of AngularJS but for now your best option is to prefix your values (and other providers) with a module name.

提交回复
热议问题