I am facing an issue with my function that uses the location
This is in my ts file:
isHomePage() {
return location.pathname == '/';
}
And here is the relevant code from my css file:
<a routerLink="/" [ngClass]="{'current-active':isHomePage()}" class="nav-link " aria-current="page">Home</a>
The function works fine in the browser, but I encountered an error in Angular CLI:
ERROR ReferenceError: location is not defined
Here's a snippet from my tsconfig.json file:
{
"compileOnSave": false,
// Other compiler options...
}