2

I want to get data of activated route by segment to check if it's company_id !== null:

/company_type/company_name/company_id/some_page

I tried const prefix = this.activatedRoute.url;. But it's giving long data. I want to get segment data of company_id.

Thank you if you provide any answer guys :)

Nodira
  • 656
  • 1
  • 9
  • 23

1 Answers1

1

Try something like

this.route.snapshot.paramMap.get('company_id');

By this way you can get data, but I think you can't check if it's null, because if it is null it should means that your url should be something like this:

company_type/company_name//some_page

and this url does not match declared route path.

A possible solution is to well manage route paths or to pass parameters by different ways. Alternatively you could do something like this:

company_type/company_name/null/some_page

but I don't know how much it can be useful

firegloves
  • 5,581
  • 2
  • 29
  • 50