Currently, I am trying to change the value of a class based on whether a user is signed in or not. I have checked the code in both app.component.ts and login.component.ts as shown below;
app.component.ts
export class AppComponent {
isAuthenticated:boolean;
constructor(private auth:Auth){
this.isAuthenticated=this.auth.authenticated();
}
}
login.component.ts
export class LoginComponent {
isAuthenticated:boolean;
constructor(private auth:Auth){
this.isAuthenticated=this.auth.authenticated();
}
}
and index.html
<body [ngClass]="{
'dashboard site-navbar-small' :isAuthenticated,
'login-form login-form-second page-login-second' :!isAuthenticated
}">
<app-root>Loading...</app-root>
Unfortunately, it seems that the changes are not being applied correctly. Here is how it appears in the browser: https://i.sstatic.net/Zl8EA.png