In my app.component.ts I have the code below to get the route name, but I always get /. Does anyone know why? I expect to get for example home, contact.
import { Component } from '@angular/core';
import { Router } from '@angular/router';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
constructor(private router: Router) {
console.log(router.url);
}
}