In the process of developing a basic Angular application using TypeScript, I have encountered an issue.
Within my project, there is a URL structure like this:
www.example.com/api/1/countries/Italy/
My goal is to extract the values 1
and Italy
from this URL and store them in variables.
I attempted to utilize ActivatedRoute
as shown below:
ngOnInit() {
this.router
.queryParams
.subscribe(params => {
this.id = +params[''];
this.country = +params[''];
});
}
The private variables id
and country
are where I intend to store the extracted values from the URL. However, I am unsure about the next steps to take...
What additional actions do I need to carry out?