Skip to content

NullInjectorError for AngularFireAuthGuard #2289

@benbabics

Description

@benbabics

Version info

Angular: 8.2.14

Firebase: 7.6.2

AngularFire: 5.3.0

Other (e.g. Ionic/Cordova, Node, browser, operating system): N/A

How to reproduce these conditions

I've captured the issue in a simple project on StackBlitz:
https://stackblitz.com/edit/angular-scftvu

Steps to set up and reproduce

  1. Open the console at the bottom of the StackBlitz-rendered browser
  2. Click between the "Public", "Protected" and "Login" hyperlinks.

Debug output

** Errors in the JavaScript console **

errors.ts:30 ERROR Error: Uncaught (in promise): NullInjectorError: StaticInjectorError(AppModule)[AngularFireAuthGuard -> Router]: 
  StaticInjectorError(Platform: core)[AngularFireAuthGuard -> Router]: 
    NullInjectorError: No provider for Router!
NullInjectorError: StaticInjectorError(AppModule)[AngularFireAuthGuard -> Router]: 
  StaticInjectorError(Platform: core)[AngularFireAuthGuard -> Router]: 
    NullInjectorError: No provider for Router!

** Output from firebase.database().enableLogging(true); **
N/A (No output)

Expected behavior

User should be navigated to the route /protected.

Actual behavior

User remains on previous route with the JS error complianing about NullInjectorError as a provider wasn't provided for Router.

I have demonstrated this on a StackBlitz Project: https://stackblitz.com/edit/angular-scftvu

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions