Upon compiling my code, I encountered the following error:
ERROR in src/app/home/home.component.ts:13:37 - error TS2339: Property 'name' does not exist on type 'string | Type'. Property 'name' does not exist on type 'string'.
13 this.pageName=route.component.name;
Surprisingly, the code works perfectly fine. The error only surfaces during the build process.
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.sass']
})
export class HomeComponent implements OnInit {
pageName;
constructor(private route: ActivatedRoute,
private router: Router) {
this.pageName=route.component.name;
}
ngOnInit() {
}
}
I've even attempted changing the ES version, but unfortunately, it did not resolve the issue.