Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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