So within my *ngfFor loop I have this
[ngClass]="{'first':isStartDate(event,day)}"
where isStartDate is a function in my component.
error thrown is
"Unexpected token : "
Is it possible to to use a function here?
So within my *ngfFor loop I have this
[ngClass]="{'first':isStartDate(event,day)}"
where isStartDate is a function in my component.
error thrown is
"Unexpected token : "
Is it possible to to use a function here?
Best way to implement it:
<div [ngClass]="ifStartDate(event,day)">
</div>
ifStartDate(event, day) {
let cssClasses;
if(some condition) {
cssClasses = {
'first': true
}
} else {
cssClasses = {
'second': true,
'third': true
}
}
return cssClasses;
}
In this way you can also apply multiple classes over div based on some condition.