Angular

GET QUERY STRING PARAMETERS

1. add this line in ts file:
import {Router, ActivatedRoute, Params} from ‘@angular/router’;

2. add below line in constructor:
constructor(private activatedRoute: ActivatedRoute) {}

3. in ndOnInit(){} put below code:
ngOnInit() {
// Note: Below ‘queryParams’ can be replaced with ‘params’ depending on your requirements
this.activatedRoute.queryParams.subscribe(params => {
const token = params[‘token’];
console.log(token);
});
}

Leave a Reply

Your email address will not be published. Required fields are marked *