I am currently using this.route.url.subscribe(params=>...
to do something with my route parameters. I want to check if some parameters are in the subscribed param array. But this array contains URLSegments
from which I only want to check for the path
attribute. Is there any way I can remap this with a map
operator?
I tried remapping the whole array like this.route.url.map(x=>x.path)
but that does not work because the array itself has no path
. Am I missing something?
I am currently using this.route.url.subscribe(params=>...
to do something with my route parameters. I want to check if some parameters are in the subscribed param array. But this array contains URLSegments
from which I only want to check for the path
attribute. Is there any way I can remap this with a map
operator?
I tried remapping the whole array like this.route.url.map(x=>x.path)
but that does not work because the array itself has no path
. Am I missing something?
2 Answers
Reset to default 9Just call map
also on the array:
this.route.url.map(x=>x.map(p => p.path))
How to map array form observable to another array
You would actually map an observable to another observable using map
(also called select
).
More
Select docs : https://github./Reactive-Extensions/RxJS/blob/master/doc/api/core/operators/select.md