Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

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');
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #angular #url #parameter
ADD COMMENT
Topic
Name
1+2 =