If I inject a service 'Z' to component 'A' which spawns a dialog component 'B' which requires the service 'Z' to be a newly fresh copy of the service (provided in 'B' again). Will closing dialog 'B' "release" that nested service 'Z' so that component 'A' will see the original 'Z' service it provided before hand? Of course service 'Z' has a unique token used in both cases.
1
There are 1 best solutions below
Related Questions in ANGULAR
- Firebase link existing user to anonymous account?
- It doesnt always show all the books on my homepage
- Google adsense ads.txt status cannot be not found
- When I navigate to the URL'http://localhost:4200/', it redirects me back
- Ionic Angular Standalone ion-icon are not showing at all
- How to make Angular understand that view child is of a specific type, not a general ElementRef?
- vscode, debug angular, first time, doesn't debug, 2nd time stops at main.js then it's ok
- How to perform CRUD operations on a static JSON array in Angular? (without API)
- Ngrx props<>() method in createAction()
- How to animate rotation of an image inside input control?
- Detecting click inside and outside of the listening component in Angular
- Angular - type guard not narrowing types
- In node_modules file i am getting Angular genric error while using fontawesome in angular12
- Angular 16 sending null values to API
- GoogleCloud Error: Not Found The requested URL was not found on this server
Related Questions in DEPENDENCY-INJECTION
- How to add logging to an abstract class in php
- Nest.js can't resolve dependencies of the external library's Reflector dependency
- Do we need IoC containers in typescript if ts-mock-imports exists
- Blazor/Razor resolve components using dependency injection
- Access Registed Scoped Services and Transient Services using GetService()
- using state data class alongside ComposeDestinations
- Messing up with conflict between spring jcl and commons-logging.jar
- How to write pytest tests for a FastAPI route involving dependency injection with Pydantic models using Annotated and Depends?
- .NET Core Include Method in Dependency Injection
- Injecting IHubContext into my background service for SignalR in .NET 5
- Issue with service method call in .NET Background Service , Issue with Scope
- How can I inject the prisma io module using inversify in my node.js project?
- Angular service injection hierarchy
- Trouble with "dotnet run seeddata" when trying to seed a database with EntityFrameworkCore. Specifically with ASP.NET Core 6 Web API
- NX Angular unit tests fail because of NullInjectorError
Related Questions in ANGULAR-DEPENDENCY-INJECTION
- How do viewProviders and @Host work together in Angular?
- Who has the responsibility to instantiate "background" services in Angular?
- Combine route resolver provider and component provider in Angular
- Creating custom Router class in Angular leads to exception
- Angular NullInjectorError under module-federation remoteEntry.js injecting an abstract service to another service across two Angular projects
- Why is my dependency injection scrambled?
- Making sure my Angular library's service is constructed offering standalone friendly provide function
- Angular Material dialog not receiving MAT_DIALOG_DATA when created from canActivate
- Error: NG0200: Circular dependency in DI detected
- angular - ERROR NullInjectorError: No provider for
- Angular: ng-content and token provision - how to make projected content find the inner templates' tokens instead the outer DOMs one?
- isolated angular service instance within an ngModule
- How to inject application config into app module in angular
- polyfills.js:1 [webpack-dev-server] Server started: Hot Module Replacement disabled, Live Reloading enabled, Progress disabled, Overlay enabled
- How do I transfer generically typed data using dependency injection?
Related Questions in ANGULAR-DI
- Can I re-provide a service for nested modal dialog component without overriding existing same token provided service?
- Lazy loading messes up DI on angular
- How to inject the right service depending on the context of UI?
- NG0200: Circular dependency in DI detected for ApplicationRef
- How to pass dynamic variable to http_interceptor from a service
- Angular: dependency injection not happening properly if we place .js or .ts at the end of import statement
- Injecting Angular service in custom Angular validator
- Providing services dynamically in Angular
- How to inject service instance into feature module in angular
- How to add http interceptor only in one specific NgModule (without lazy-loading)?
- Angular dynamic DI with string token
- Why doesn't Angular CLI add services in providers array automatically?
- Is using @Injectable providedIn for any non-lazy-loaded module the same as providedIn: "root"?
- Angular DI - useFactory - Provider : Is there a way to invoke Provider Factory function second time when local State gets updated?
- how to provide another control value accessor?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Yes, you can, you just add service
Zto the providers of componentB(the dialog).The lifecycle of
Zwill be tied toB. There might be other instances ofZprovided elsewhere, with different lifecycle, but the one provided byBwill shadow the other instances, ie.Bwill get the instance coming from the provider from its own@Component. Note that this applies toB's child component, ie. this way the serviceZis also shadowed for those by this instance.To verify such situations (eg. what the lifecycle of things is, who gets which instance), I usually do the following
constructorandngOnDestroyof the items on question, eg. forBandZin this caseIn this case, you would observe that possibly some instances of
Zare created before the dialogBis instantiated, but more importantly a new one will be instantiated forBand also, it will be destroyed together withB.Regarding this remark:
You probably don't need that, you can use a single token, possibly
Zitself. The injection token is only for finding the provider, doesn't directly influence the lifecycle. The lifecycle depends on where the provider is.