How to get query parameters from URL in Angular 5?
Hi everyone! I'm new to Angular (version 5) and trying to figure out routing. I have a product list page, and I want to pass parameters to it via URL, for example: `/products?category=electronics&page=2`. \n\nI've already set up basic routing, but I can't figure out how to get the `category` and `page` values inside the `ProductsComponent`. I tried using `ActivatedRoute`, but it's not working. Here's my code:\n\n```typescript\n// products.component.ts\nimport { Component, OnInit } from '@angular/core';\nimport { ActivatedRoute } from '@angular/router';\n\n@Component({\n selector: 'app-products',\n templateUrl: './products.component.html'\n})\nexport class ProductsComponent implements OnInit {\n constructor(private route: ActivatedRoute) { }\n\n ngOnInit() {\n
No answers yet.
Log in to leave an answer