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
Post a Comment