1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Angular getting URL paramters doesn't work as it should

Discussão em 'Angular' iniciado por ZaTTTel, Outubro 2, 2024.

  1. ZaTTTel

    ZaTTTel Guest

    I need to retrieve URL queries as in www.website.com?a:b. For this I followed this official angular tutorial, leading me to this simple code inside my component:

    constructor(private route: ActivatedRoute) {}

    ngOnInit() {
    this.route.queryParams.subscribe(params => {
    console.log(params)
    })
    }


    This triggers the following error in the console:


    ERROR NullInjectorError: R3InjectorError(AppModule)[ActivatedRoute -> ActivatedRoute -> ActivatedRoute]: NullInjectorError: No provider for ActivatedRoute!
    ​

    Event though it is not mentioned in the tutorial, I add ActivatedRoute to my app.module.ts. This generates a different error:


    Error: NG0204: Can't resolve all parameters for ActivatedRoute: (?, ?, ?, ?, ?, ?, ?, ?).
    ​

    I cannot tell why noone else has had this issue, does anyone know what the problem might be? Thanks.

    Continue reading...

Compartilhe esta Página