1. 5
    Define and read route parameters with the Angular router
    2m 47s

Define and read route parameters with the Angular router

Share this video with your friends

Send Tweet

An Angular URL can be structured into segments, each of which is formed by its path and series of additional information such as parameters, query parameters and fragment. Parameters are a way to provide a per segment scoped information, such as the ID of an object to be visualized by the activated component. In this lesson we learn how to define and read route parameters from within an Angular component in order to further process it.

Konstantinos
~ 6 years ago

Hello, could you please explain what is the difference between the ActivatedRoute and the ActivatedRouteSnapshot?

Juri Strumpflohnerinstructor
~ 6 years ago

Hey sure. It's basically as I mention in the video. the ActivatedRoute returns an RxJS Observable to which you can subscribe and get notified whenever the URL params change. This is especially useful if your component remains active while the route changes such as in the example of this video lesson.

On the other side, if you're sure your component gets destroyed every time the route changes, i.e. when navigating from a list to the detail view and back again, then you could also rely on the ActivatedRouteSnapshot which contains the same values as the ActivatedRoute but not in the form of an Observable, but the plain resolved values.