I have a problem with a ngClass and a function with building an app with Ionic 2 and Firebase. The function does work, but the value of the function does not come in the HTML code. I have used this as an example: https://codepen.io/andre13/pen/oecgi.
The html and the call for the function looks like this:
<button ion-button class="chatbutton" [ngClass]="compareUser(user.$key)"
(click)="gotoDoctorChat(user.$key)" >{{user.naam}} </button>
The function looks like this:
compareUser(uid){
this.angFire.database.object('/users/' + uid +'/'+ this.coach1+'red').subscribe(snapshot=>{
console.log("snapshot.tostring = " + snapshot.$value);
if(snapshot.$value === '0'){
return 'unread';
}else{
return null;
}
})
};
The CSS looks like this:
.unread{
background-color: red!important;
}
Please ask if something is not clear.