Now I know that global variables are an anti-pattern and, perhaps, moreover, in the Angular world than in other places ... however, I came across a situation where I tend to break the rule ...
I read the comments here and I completely agree with all the posters that point to the anti-angular 'ism, which represents my idea, and the anti-template in general ...
Angular JS - Make the service globally accessible from controllers and view
However, now for my use case, I have a $ theme service that contains many variables and constants, such as paths to images and strings.
We also have a structure of components that become accessible to application developers by directives, allowing us to create most of our applications using only our internal structure in the form of markup directives.
I could create directives for each of the needs, however it would bring sacrifices of flexibility with a low connection between views and themes, allowing developers to access the $ theme service directly in the views, without having to (rewrite) controllers (or even create controllers for everything) or implement new directives, this will allow them to work exclusively in the markup available to them by the internal structure. Basically, I want application developers to be able to work exclusively in markup. We also created directives that link ngResource links and expose resource methods in the current $ area, as well as directives that link the current $ variable to variables in the $ stateParam service, etc. Etc., I hope you get an image ...
eg.
<h1>{{$root.$theme.NAME}}"</h1>
<img my-src="$root.$theme.logo.url" />
...
<my-theme-name />
<h1 my-theme-name />
<my-theme-logo />
<img my-theme-logo />
, , , , , , . , , .
, , , , , , $theme ...
, , , , , , , Angular2 - , , - , , .
, , , , $root ?
_____ 7 2016 _____
, , $fileSaver , , "" , <my-injector my-name="$theme" />, , myName .
:
<my-injector my-name="$theme" />
<img ng-src="$theme.logo.url" />
, . <my-import my-name"$theme" /> , ...