One thing I consistently do is inject
app.constant('DOCUMENT_ID', window.documentId || 1);
into services, controllers, and directives.
I'm now looking to convert DOCUMENT_ID
into a global variable. The goal is for any changes made to DOCUMENT_ID
in a controller to be reflected in all services and controllers where DOCUMENT_ID
was injected. How can I achieve this using a global variable?