Hi I am trying to extract the id part of the url using Angular2.
http://localhost:3000/item/187809
I have been playing around with ActiveRoute
I suspect the issue is that you're using queryParams
instead of just params
.
params: An Observable that contains the required and optional parameters specific to the route.
queryParams: An Observable that contains the query parameters available to all routes.
so try this:
this.route.params.subscribe(params => {
console.log(params);
console.log(+params['id']);
});