Coder Social home page Coder Social logo

Comments (3)

garrettld avatar garrettld commented on June 3, 2024 3

You're providing the Router class in a couple components. The Router should only be provided once, in the root, with provideRouter.

Re-providing it causes the child Router to be destroyed when the view that provides it is destroyed, which completes the navigation transitions observable, so the root router never sees any additional navigation events. Your app should work normally if you remove Router from your component providers arrays.

It would be nice if there was a runtime warning when multiple Router instances were detected.

from angular.

jamesmcging avatar jamesmcging commented on June 3, 2024 1

You're providing the Router class in a couple components. The Router should only be provided once, in the root, with provideRouter.

Re-providing it causes the child Router to be destroyed when the view that provides it is destroyed, which completes the navigation transitions observable, so the root router never sees any additional navigation events. Your app should work normally if you remove Router from your component providers arrays.

It would be nice if there was a runtime warning when multiple Router instances were detected.

@garrettld, you're a star, I've just spent 3 days trying to work out why exactly this was happening to me and you answered in your first line.

from angular.

BnSmth avatar BnSmth commented on June 3, 2024

Thank you so much @garrettld, that's resolved the issue. Totally agree that some sort of warning should be raised if multiple instances are detected (at least when running in dev mode). Thanks again, this was an incredibly frustrating issue that was really bumming me out!

from angular.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.