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.
app.module.tsfile??a:bisn't a query parameter. But also noteActivatedRouteis already provided (along with all of its dependencies) by theRouterModule, which you should have set up as shown in angular.io/guide/router#defining-a-basic-route.