0

I have a set of routes like this:

/users/:type/:id
/users/admin/:id
/user/manager/:id

Now all of these use the same component. The catch is, admin and manager can see some extra stuff based on their type. Assuming I don't have a way to get these from user roles and then show the relevant information, can I use the type route param to identify if the user is admin, manager or any other type of user?

Essentially, in my init function, I am setting something like this:

this.userType = params.userType;

This will work in case of first route as we have a param set for type. Can I tell angular that the value admin and manager are actually the value of param type?

Vivek V Dwivedi
  • 2,510
  • 2
  • 28
  • 39

1 Answers1

0

you can use activatedroute to get the query params

first in the constructor you have to declare activateroute something like this

constructor(private activatedRoute: ActivatedRoute){}

Import activated route and then on ngonit you write the following code to get the values

this.activatedRoute.queryParams.subscribe(params=>{
    this.user=params.type;
    this.id=params.id
})