I am currently working on a project where I need to keep a log of every page that is accessed in my Angular application.
Here is an overview of my routing setup:
const routes: Routes = [
{ path: ':id', component: AppComponent}
];
Within my app component's TypeScript file, in the ngOnInit()
method, I have added the following code:
ngOnInit() {
console.log(this.router.url);
}
For example, when trying to access the URL /testing123,
I am expecting the log to show "/testing123", However, it is currently only logging "/" without passing the ID.