dependency injection - Module-specific constants in AngularJS? -


i discovered knew nothing angular modules.

the value of con in following directive baz, means not matter constant defined, i.e. not module dependant.

is there way have module-specific constants?

angular.module('amodule', [])     .constant("foo", "bar")     .directive('helloworld', function (foo) {         return {             link: function(scope) { scope.con = foo },             restrict: 'e',             scope:{                 name:'bind'             },             template: '<span>{{con}}</span>'          }     })  angular.module('stuff', [])     .constant("foo", "baz")  angular.module('helloapp', ['amodule', 'stuff']) 

no, when define angularjs artifact on module available modules if reference them in app module. if 2 modules define same constant last dependency defined wins , overrides first one. order key in context. in case value of con baz because last module referenced stuff.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -