Skip to content

Instantly share code, notes, and snippets.

@NetanelBasal
Created May 19, 2022 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NetanelBasal/a0c32a01bcc8c4d6bec18ba9b33c32cd to your computer and use it in GitHub Desktop.
Save NetanelBasal/a0c32a01bcc8c4d6bec18ba9b33c32cd to your computer and use it in GitHub Desktop.
import { inject } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
export function getRouteParam(key: string) {
return inject(ActivatedRoute).snapshot.params[key];
}
@Component({
selector: 'app-todo-page',
templateUrl: './todo-page.component.html',
})
export class TodoPageComponent {
id = getRouteParam('id');
ngOnInit() {
console.log(this.id)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment