Answers for "how to read the url parameter of user in angular"

7

angular get url param

constructor(private activatedRoute: ActivatedRoute) {
  this.activatedRoute.queryParams.subscribe(params => {
        let date = params['startdate'];
        console.log(date); // Print the parameter to the console. 
    });
}
Posted by: Guest on November-25-2020
0

angular get url parameter

Routes

export const MyRoutes: Routes = [
    { path: '/items/:id', component: MyComponent }
]


Component

import { ActivatedRoute } from '@angular/router';
public id: string;

constructor(private route: ActivatedRoute) {}

ngOnInit() {
   this.id = this.route.snapshot.paramMap.get('id');
}
Posted by: Guest on March-03-2022
2

angular get url params

import { ActivatedRoute } from "@angular/router";

//import ActivatedRoute in constructor()
private $route: ActivatedRoute

// in ngOnInit() call
//myvar is the variable where you want to store your param
this.$route.params.forEach(param =>
	this.myvar = param['whatever your param name is']
);
Posted by: Guest on March-19-2020

Code answers related to "how to read the url parameter of user in angular"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language