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?
Add a comment
|
2 Answers
Just call map also on the array:
this.route.url.map(x=>x.map(p => p.path))
1 Comment
moessi774
Works perfectly. Thank you for helping me out everytime :)
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.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/operators/select.md
1 Comment
moessi774
Are there any advantages over Günter`s solution?