3

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 2

9

Just call map also on the array:

this.route.url.map(x=>x.map(p => p.path))
Sign up to request clarification or add additional context in comments.

1 Comment

Works perfectly. Thank you for helping me out everytime :)
2

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

Are there any advantages over Günter`s solution?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.