I have add the provider for activedroute and now it give this error, i want to get query string parameter, for example : http://localhost:4200/?user=hello
I want get value of user, this is my code :
import { Component, OnInit, Input } from '@angular/core';
import {Router, ActivatedRoute, Params} from '@angular/router';
@Component({
selector: 'app-login',
templateUrl: './login.html'
})
export class LoginBancaComponent implements OnInit {
constructor(private route: ActivatedRoute){}
ngOnInit() {
this.activatedRoute.params.subscribe((params: Params) => {
let str= params['user'];
console.log(str);
});
}
}
But on console page there is this error:
Can't resolve all parameters for ActivatedRoute: (?, ?, ?, ?, ?, ?, ?, ?).
I have import everything in module :
import {Router, ActivatedRoute, Params} from '@angular/router';
...
imports: [
BrowserModule,
CommonModule, RouterModule,
],
providers: [ActivatedRoute],
...
Why there is this error ?