user2837961
user2837961

Reputation: 1555

Rxjs Pipes parameter values

Can I do this at all? Sorry very new to angular

 this.route.paramMap
.pipe( map( p => p.get( 'id' ) ) )
.pipe(
    switchMap( id => this.MyService.getMyProjectData( +id ) ),
    map( items => this.MyListMapper( items, +id ) )  // I want to pass the id here from first pipe
    )

In the second pipe, I want to use the same parameter value

Upvotes: 1

Views: 107

Answers (1)

Eldar
Eldar

Reputation: 10790

Yes, you can :

this.route.paramMap
.pipe( 
      map( p => p.get( 'id' ) ) , 
      switchMap( id => this.MyService.getMyProjectData( +id )
                          .pipe( map( items => this.MyListMapper( items, +id ) ) )
          )
   );

Upvotes: 2

Related Questions