Can I use the Angular custom service before downloading?

I have a service:

angular.module('USC').service('TemplateService', function() {});

What I would like to use before manually loading an Angular project:

angular.bootstrap(document, ['USC']);

Is it possible? I know that I can call var service = angular.bootstrap (). Get (); for Angular services, but how would I call a custom option before the module was initialized?

+4
source share
1 answer

If it's ok to have a different service instance than the one that will be used by the application itself, you can achieve what you want:

angular.injector(['ng', 'yourApp']).get('SomeService').doStuff();

. .
< > , ( 0) Angular. >

+8

Source: https://habr.com/ru/post/1541163/


All Articles