Say I have a link localhost:4200/details/1 I want to subscribe only to changes in the "details" part of the URL. i.e. when "details" changes to some other word and not the other parts of the URL. How do I do it?
CodePudding user response:
You have to
- Subscribe to all changes
- Map to required property
- use
distinctUnilChangedoperator
eg.
private route:ActivatedRoute
this.route.params.pipe(
map(params => params.yourParamName),
distinctUntilChanged(),
).subscribe(changedParam => console.log(`reacting to single param change ${changedParam}`));
CodePudding user response:
You can subscribe to the activatedRoute url, and just get the first segment. Ref. 
