DI - Handle the "InjectFlags" in Injector_.get()
See original GitHub issueπ feature request
Relevant Package
This feature request is for @angular/coreDescription
At the moment the Injector_.get()
implementation doesnβt handle the InjectFlags
.
Iβd like the feature so that I can use the component Injector
like this:
@Component(...)
export class SomeComponent {
// Here I get an instance of Injector_
constructor(injector: Injector) {
this.myService = injector.get(SomeService, null, InjectFlags.SkipSelf);
}
}
Describe the solution youβd like
It looks like you already handle the DeepFlags
. refs.ts:342
You probably just need to map and pass the InjectFlags
to the resolveDeep()
function
class Injector_ implements Injector {
...
get(token: any, notFoundValue: any = Injector.THROW_IF_NOT_FOUND): any {
...
return Services.resolveDep(
this.view, this.elDef, allowPrivateServices,
{flags: DepFlags.None, token, tokenKey: tokenKey(token)}, notFoundValue);
}
}
I donβt think I have enough knowledge of the project to submit a PR by myself, so Iβm relying on you for this.
Thanks in advance for your work
Issue Analytics
- State:
- Created 4 years ago
- Reactions:16
- Comments:13 (3 by maintainers)
Top Results From Across the Web
Injector - Angular
get() link Β· mode_edit code. Retrieves an instance from the injector based on the provided token. 4 overloadsΒ ...
Read more >Angular Injector, have multiple InjectFlags in get method
How can we have multiple InjectFlags? Something for eg. that would resemble @Optional() @SkipSelf() private _type1: Type1;.
Read more >A Deep Dive into @Injectable and providedIn in Ivy - Angular ...
In this article I want to explain how Angular @Injectable decorator works under the hood and how providedIn property is processed by AngularΒ ......
Read more >Using root-provided Injectables in non-DI places | tnc
Imagine you have a LogService that will handle API errors and log the ... It is going to get very verbose to apply...
Read more >Injector - Angular ζ₯ζ¬θͺγγγ₯γ‘γ³γγΌγ·γ§γ³
Injectors are configured with providers that associate dependencies of various types with injection tokens. ... "DI Providers". ... get()link.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I would call it a bug, not a feature: The provided Injector clearly does not behave as defined by the API documentation:
https://angular.io/api/core/Injector
NodeInjector
isnβt passing the flag here di.ts#L628