Skip to content

Instantly share code, notes, and snippets.

@rajaramtt
Last active August 21, 2020 11:00
Show Gist options
  • Save rajaramtt/ec2edbacb84182055193e18eb4d3ddbf to your computer and use it in GitHub Desktop.
Save rajaramtt/ec2edbacb84182055193e18eb4d3ddbf to your computer and use it in GitHub Desktop.
Angular Query string and parameters example
import { Router, ActivatedRoute, Params } from '@angular/router';
constructor(
private router: Router,
private route: ActivatedRoute,
) { }
const queryString = this.route.snapshot.queryParamMap.get('queryString');
this.route.queryParams.subscribe(params => {
const queryString = params['queryString'];
});
this.route.params.subscribe((params: Params) => {
const parameterID params['paramterID']
});
const parameterID = this.route.snapshot.paramMap.get('parameterID');
const parameterID = this.route.snapshot.params.parameterID;
this.router.navigate(['/url', paramsID]);
this.router.navigate(['/url'], { queryParams: { query: 'queryvalue' } });
--------------------------------------------
private route: ActivatedRoute,
--------------
{
path: 'xxxxx',
component: xxxxxComponent,
data: { page: 'xxx-flow' }
},
this.pageFlow = this.route.snapshot.data.page;
or
this.route.data.subscribe(data => {
debugger;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment