How to pass query parameters with a routerLink ? Last Updated : 22 Jul, 2020 Comments Improve Suggest changes Like Article Like Report The task is to pass query parameters with a routerLink, for that we can use the property binding concept to reach the goal. Using property binding, we can bind queryParams property and can provide the required details in the object. What is Property Binding? It is a concept where we use square bracket notation to bind data to Document Object Model(DOM) properties of Hypertext markup language(HTML) elements. Syntax: <a [routerLink]="[/path]" [queryParams]="{property:value}"> State Details </a> An Example of property binding: JavaScript import { Component, OnInit } from '@angular/core' @Component({ selector: 'app-property', template: // Property Binding `<p [textContent]="title"></p>` }) export class AppComponent implements OnInit { constructor() { } ngOnInit() { } title = 'Property Binding example in GeeksforGeeks'; } Output: Illustration of above code Approach: First, configure the routes in app.module.tsImplement query params with required values in the HTML file.Then in .ts file, in ngOnit try to access the query params using the activated Route by importing it from 'angular@router'Once you are able to access them try to render them by using either string interpolation syntax or property binding syntax in HTML file. Below is the implementation of the above steps: app.module.ts: JavaScript import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; // Importing Routes import { RouterModule, Routes } from '@angular/router'; import { AppComponent } from './app.component'; import { StateComponent } from './state/state.component'; // Configuring Routes const routes: Routes = [{ path: 'punjab', component: StateComponent },]; @NgModule({ imports: [BrowserModule, R outerModule.forRoot(routes)], declarations: [AppComponent, StateComponent], bootstrap: [AppComponent] }) export class AppModule { } app.component.html: HTML <a [routerLink]="['/punjab']" [queryParams]= "{capital:'mohali',language:'punjabi'}"> State Details </a> <router-outlet></router-outlet> After clicking on the anchor tag the URL will be displayed in the following way: We can also access the query parameters using the activated route. In this way, we can pass query parameters via routerLink. Fetching of query parameters: state.component.ts : JavaScript import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; @Component({ selector: 'app-state', templateUrl: './state.component.html', styleUrls: ['./state.component.css'] }) export class StateComponent implements OnInit { capital: string; language:string; constructor(private route: ActivatedRoute) { } ngOnInit() { this.route.queryParams.subscribe( params => { this.capital = params['capital']; this.language=params['language']; } ) } } state.component.html: HTML State Details are : <p>Capital : {{capital}} </p> <p>Language : {{language}} </p> Output: Before Click the Button: After Click the Button: Hence query parameters passed can be seen Comment More infoAdvertise with us Next Article How to pass query parameters with a routerLink ? B bunnyram19 Follow Improve Article Tags : JavaScript Web Technologies AngularJS JavaScript-Misc AngularJS-Misc +1 More Similar Reads GET Request Query Parameters with Flask In this article, we will learn how we can use the request object in a flask to GET Request Query Parameters with Flask that is passed to your routes using Python. As we know, Flask is a web development framework written in Python, and the flask is widely used as a web framework for creating APIs (Ap 4 min read How to Set URL Query Params in Vue with Vue-Router ? Vue Router is a navigation library designed specifically for Vue.js applications. In this article, we will learn about the different methods of setting the URL query params in Vue with Vue-Router. Below is the list of all possible methods.Table of ContentUsing router-linkUsing push() methodUsing rep 6 min read Multi-value Query Parameters with Flask Flask is a micro-framework written in Python. It is lightweight, and easy to use, making it famous for building RESTful APIs. In this article we are going to see how to use Multi-value query parameters with flask. You can know more about it here. Let's understand the basics with an example: Python3 2 min read How to Get Query String Parameter in SvelteKit? In this article, we will explore how to retrieve query string parameters in SvelteKit applications. Query parameters are often used to pass data in URLs, such as user preferences or search queries. Understanding how to access these parameters is crucial for building dynamic web applications.These ar 3 min read Reading Query Parameters in Node In Node.js, query parameters are typically accessed from the URL of a GET request. When using the core HTTP module or a framework like Express, query parameters can be parsed and accessed for dynamic functionality.A query string refers to the portion of a URL (Uniform Resource Locator) that comes af 2 min read How to Access Request Parameters in Postman? Request parameters are additional pieces of information sent along with a URL to a server. They provide specific details about the request, influencing the server's response. Parameters typically follow a 'Key=Value' format and are added to the URL in different ways depending on their type.Table of 4 min read How to pass parameters in Postman requests? Postman is an API(application programming interface) development tool that helps to build, test and modify APIs. It can make various types of HTTP requests(GET, POST, PUT, PATCH), save environments for later use, and convert the API to code for various languages(like JavaScript, and Python). In this 2 min read How to Get Query Parameters from a URL in VueJS ? Query parameters are part of a URL that assigns values to specified parameters. They start after the question mark and are separated by ampersands ("&") in the URL. For example, in the URL https://example.com?name=John&age=23, name=John and age=23 are query parameters. The below-listed metho 8 min read How to Get Parameter Value from Query String in ReactJS? In React query parameter are a way to pass the data as props from the url to react components. Getting parameter value from query string helps to render the dynamic data depending on the query.ApproachTo get the parameter value from query string in React we will be using the query-string packge. We 2 min read How To Use Query Parameters in NestJS? NestJS is a popular framework for building scalable server-side applications using Node.js. It is built on top of TypeScript and offers a powerful yet simple way to create and manage APIs. One of the core features of any web framework is handling query parameters, which allow developers to pass data 6 min read Like