question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to inject component into global guards,filters,pipes and interceptors?

See original GitHub issue

Hi, Right now dependency injection is not possible in global pipes,guards,filters and interceptors (#230), is there any way to set globality inside decorator?

@Guard({global:true}) //or @Guard(true)
export class AuthGuard implements CanActivate{
      constructor(private authService: AuthService) {
      }
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:16 (5 by maintainers)

github_iconTop GitHub Comments

17reactions
myflowplcommented, Dec 22, 2017

I have to say, the way you have to configure global stuff is so weird, comparing to how nice other things are architected

as @br0wn suggested, it would be much better to have the top module have all global stuff and all child modules just inherits it, like @wbhob suggested

2reactions
br0wncommented, Dec 13, 2017

Global guards, interceptors etc. live outside any module, so they can’t inject anything. It won’t be possible because we don’t have a ‘global scope’.

How about treating global guards, interceptors, etc. as part of root application module?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Inject http interceptor at component - angular - Stack Overflow
No, it's called once, stackblitz.com/edit/angular-fxrajv . Any way, as it was noted, a proper way is to store loading state in separate service....
Read more >
9 Using Contexts and Dependency Injection for the Java EE ...
Dependency injection. This feature enables you to inject components into an application in a type-safe way and to choose at deployment time which...
Read more >
Introduction to Contexts and Dependency Injection - Quarkus
In this guide we're going to describe the basic principles of the Quarkus programming model that is based on the Contexts and Dependency...
Read more >
Multiple Interceptors in Angular | Hossein Mousavi | CodeX
We can use Interceptors to intercept the incoming and outgoing HTTP requests and manipulate them using Angular HttpClient.
Read more >
Interceptors - EF Core - Microsoft Learn
Interceptors are different from logging and diagnostics in that they allow modification ... Example: Command interception to add query hints.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found