I am making a simple Angular (version 4) application with TypeScript.
I have an URL that looks like this:
www.example.com/api/1/countries/Italy/
And I want to get 1
and Italy
from this URL and assign them to variables.
I tried with ActivatedRoute
like this:
ngOnInit() {
this.router
.queryParams
.subscribe(params => {
this.id = +params[''];
this.country = +params[''];
});
}
Where id
and country
are my private variables I want to assign with the values from the URL. But I don't know how exactly to proceed...
What else do I need to do?