As I was trying to retrieve URL queries like www.website.com?a:b
, I decided to follow the guidance provided in a particular Angular tutorial. This official tutorial (accessible via this link) instructed me to implement the following simple code snippet within my component:
constructor(private route: ActivatedRoute) {}
ngOnInit() {
this.route.queryParams.subscribe(params => {
console.log(params)
})
}
Surprisingly, executing this code triggered an error message in the browser console:
ERROR NullInjectorError: R3InjectorError(AppModule)[ActivatedRoute -> ActivatedRoute -> ActivatedRoute]: NullInjectorError: No provider for ActivatedRoute!
Despite the absence of any mention about it in the tutorial, I proceeded to add ActivatedRoute
to my app.module.ts
. To my dismay, this modification led to yet another error:
Error: NG0204: Can't resolve all parameters for ActivatedRoute: (?, ?, ?, ?, ?, ?, ?, ?).
Curiously, it seems like no one else encountered this issue before. As I am puzzled by this problem, I wonder if anyone has insights into what might be causing it. Any help or suggestions would be greatly appreciated. Thank you.