Inject constant to other modules config using Angular JS

Your info constant is defined in your myApp module. If I understand your question correctly, you’d like to use the constants in other modules (e.g. myApp.orders module). If so, then you need to inject myApp into myApp.orders, but it looks like you want to do the reverse. One solution is to decouple the constants into a standalone module, and inject it as a dependency where needed.

angular.module('constants', []) 

angular.module('myApp', ['constants', 'myApp.orders'])

angular.module('myApp.orders', ['constants'])

Leave a Comment