Answers for "extract path params from url 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
0

in angular how to get router url without query params

this.router.url.split('?')[0]
Posted by: Guest on October-06-2020

Code answers related to "extract path params from url angular"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language