1

I know that both of ActivatedRoute.params.forEach and ActivatedRoute.params.subscribe will return the paramaters set into route config.

Into my configuration for example:

{ path: 'auditioning/:casterType/list', component: AuditionComponent } 

When I check the parameters I do this:

this._activatedRoute.params.subscribe( (params) => { console.log(params) // return object of parameters } ); 

Or

this._activatedRoute.params.forEach( (params) => { console.log(params) // return object of parameters } ); 

When I should use forEach or subscribe when getting params into path because both of them return the result what I want?

What is the best practice?

1

1 Answer 1

1

When you see the Docs it is of type Observable,

So I always use the

this._activatedRoute.params.subscribe( (params) => { console.log(params) // return object of parameters } ); 

I hate using forEach on observables as it might cause a lot of troubles.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.