I am trying to add a class when Im on a specific route. The code is in my AppComponent, Im using ngClass.
@Component({ selector: 'my-app', template: `<a [ngClass]="getRoute(router)">
and then I have a function on the same app.component.ts
export class AppComponent { getRoute(){ if (this.router.url === '/atendimento'){ return "hide-bar"; } } }
The error I am getting is the following:
Property 'router' does not exist in type 'AppComponent'
And yes, I import Routes, RouterModule and Router in the header. Can anybody help me?
Thank you in advance
source share