I want to use [ngClass]
with a method call that returns an object like {currentWeek: true}
and I want to add the var week.state
that can have the value rejected
.
I want that the HTML looks like this: <div class="currentWeek rejected"></div>
but when I use it I get this error:
Error in ./FlexCalendar class FlexCalendar - inline template:29:13 caused by: NgClass can only toggle CSS classes expressed as strings, got [object Object]
How can I combine a method call and a variable into the ngClass? Something like [ngClass]=[setWeekClasses(week), week.state]
setWeekClasses(week: Week): Object {
let state: string = this.state(week.state);
return {
'currentWeek': week.weekNumber === this.selectedDate.getWeekNumber(),
[week.state]: true,
};
}
[ngClass]=setWeekClasses(week)
that's it – Contrarily