Last active
August 21, 2020 11:00
-
-
Save rajaramtt/ec2edbacb84182055193e18eb4d3ddbf to your computer and use it in GitHub Desktop.
Angular Query string and parameters example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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