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.
});
}
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.
});
}
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');
}
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']
);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us