Issue
I am trying to get url parameter value but it is undefined and I don't find why...
Code
export class HeaderComponent implements OnInit {
constructor(private route: ActivatedRoute) { }
ngOnInit(): void {
console.log(this.route.snapshot.params['lang']);
}
}
URL
localhost:4200/home?lang=EN
Solution
What you are looking for is queryParams
not params
.
params
is for myRoute/mySubRoute/:myParam:/
queryParams
is for myRoute/mySubRoute?param=value
where ?param=value
is the queryString
.
Answered By - Matthieu Riegler
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.