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 Create Quiz Comment B bunnyram19 Follow 0 Improve B bunnyram19 Follow 0 Improve Article Tags : AngularJS JavaScript-Misc AngularJS-Misc Explore AngularJS BasicsAngularJS Tutorial 5 min read Introduction to AngularJS 4 min read Angular CLI | Angular Project Setup 3 min read AngularJS Expressions 2 min read AngularJS Modules 3 min read AngularJS ng-model Directive 4 min read AngularJS Data Binding 4 min read AngularJS Controllers 3 min read AngularJS | Scope 2 min read AngularJS Services 4 min read AngularJS | AJAX - $http 3 min read AngularJS | Tables 2 min read AngularJS Select Boxes 2 min read AngularJS SQL 3 min read AngularJS HTML DOM 2 min read AngularJS Events 3 min read AngularJS | Forms 3 min read AngularJS Form Validation 3 min read AngularJS | API 2 min read AngularJS and W3.CSS 2 min read AngularJS Includes 3 min read AngularJS Animations 1 min read AngularJS | Application 3 min read AngularJS DirectivesAngularJS Directives 9 min read AngularJS ng-app Directive 1 min read AngularJS ng-bind Directive 2 min read AngularJS ng-bind-html Directive 2 min read AngularJS ng-bind-template Directive 2 min read AngularJS ng-blur Directive 1 min read AngularJS ng-change Directive 2 min read AngularJS ng-checked Directive 2 min read AngularJS ng-class Directive 2 min read AngularJS ng-class-even Directive 2 min read AngularJS ng-class-odd Directive 2 min read AngularJS ng-click Directive 2 min read AngularJS ng-cloak Directive 2 min read AngularJS ng-controller Directive 2 min read AngularJS Directives Complete Reference 2 min read AngularJS FiltersAngularJS | Filters 7 min read AngularJS currency Filter 2 min read AngularJS | date Filter 2 min read AngularJS filter Filter 3 min read AngularJS json Filter 2 min read AngularJS limitTo Filter 2 min read AngularJS lowercase Filter 1 min read AngularJS number Filter 1 min read AngularJS orderBy Filter 4 min read AngularJs uppercase Filter 1 min read AngularJS Converting FunctionsAngularJS angular.lowercase() Function 2 min read AngularJS angular.uppercase() Function 1 min read AngularJS angular.forEach() Function 1 min read AngularJS Comparing FunctionsAngularJS angular.isArray() Function 2 min read AngularJS angular.isDate() Function 2 min read AngularJS angular.isDefined() Function 2 min read AngularJS angular.isElement() Function 2 min read AngularJS angular.isFunction() Function 2 min read AngularJS angular.isNumber() Function 2 min read AngularJS angular.isObject() Function 2 min read AngularJS | angular.isString() Function 1 min read AngularJS angular.isUndefined() Function 2 min read AngularJS angular.equals() Function 2 min read AngularJS angular.toJson() Function 2 min read AngularJS QuestionsHow to bundle an Angular app for production? 4 min read How to add many functions in one ng-click directive? 2 min read How to directly update a field by using ng-click in AngularJS ? 3 min read How to Add Dynamic Options for Multiple Selects Inside ng-repeat Directive ? 3 min read How to detect when an @Input() value changes in Angular? 3 min read How to open popup using Angular and Bootstrap ? 2 min read How to reload or re-render the entire page using AngularJS? 2 min read How to add input fields dynamically on button click in AngularJS ? 2 min read How to Create Button Dynamically with Click Event in Angular ? 2 min read How to use jQuery in Angular ? 2 min read AngularJS Examples 2 min read Like