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 know I'm a bit late with a reply, but just in case you were still having problem please take a look at the Angular documentation.
angular routing tutorial
Look at the example from the link.
Start by importing ActivatedRoute:
import { ActivatedRoute } from '@angular/router';
Then inject it in the constructor
constructor(private route: ActivatedRoute) {}
And in OnInit()
ngOnInit(): void {
const id = this.route.snapshot.paramMap.get('id');
}
and like this you don't need to worry about any Observables directly.
Hope this helps you.