Is it possible to start the angular 2 service at startup? bootstrap does not execute a service counter. And also the injector executes the service controller every time there is an injection of the service in some component. is there any way to make singelton service and make sure ctor will work only once?
Add service only for bootstrapping, not for excerpts in your components. If you add it to your AppComponent, it will be created only once.
Adding a service to providers in a component creates a new instance for each instance of the component.
Bootstrap , , . , .
(LogRepository) , . ( LogRepository) bootstrap(TheApp, [HTTP_PROVIDERS,LogRepository]);
bootstrap(TheApp, [HTTP_PROVIDERS,LogRepository]);
, , , bootstrap(). .
Source: https://habr.com/ru/post/1625183/More articles:There is no way out when using cUrl - phpHow to print a custom description of the Swift structure during debugging, and nothing more? - xcodeAre C ++ `try` /` catch` blocks the same as other blocks with respect to RAII? - c ++Unlist to create a unique row in a dataframe - grepAzure SQL Data Warehouse bandwidth limits? - azurePath-specific typing by coincidence / case - scalaBest way to have all files in a directory - webpack entry points? - javascriptGet python decorator arguments at runtime - pythonHow to close a file after the stream ends? - scala"You must enter a valid value" for input type = "number" with the correct number - internet-explorerAll Articles