最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to map array form observable to another array - Stack Overflow

programmeradmin0浏览0评论

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?

Share Improve this question asked Aug 25, 2016 at 6:18 moessi774moessi774 1,0992 gold badges12 silver badges20 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 9

Just 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

发布评论

评论列表(0)

  1. 暂无评论