I have a [ngClass] that seems to be working correctly on my local environment but not on the Production environment. I'm not able to replicate the issue since it works on local environment but if I debug on the prod using the developer tool I can see that it does apply the class but then it removes it afterwards.
If the [ngClass] doesn't work properly on PROD what might be the alternative way ?
CSS
#main .drawing-select {
min-width: 285px;
margin-bottom: 15px;
}
#main .highlight {
border: 3px solid #66bb6a;
}
HTML
<div cdkDropList class="drawing-select-container" (cdkDropListDropped)="drop($event)">
<div *ngFor="let c of configs;let i = index" cdkDrag>
<mat-card [ngClass]="outLine(c.UpdatedTimestamp)" (click)="selectConfig(i)" fxLayout="column" fxLayoutAlign="center center"
@fadeInAnimation>
<img src="{{ c.SignedUrl }}&width=200&height=150" />
<span>{{c.Content.Title}}</span>
</mat-card>
</div>
</div>
TS
public outLine(timeStamp: Date): any {
const date = new Date();
const currentDate = moment(date, 'YYYY-MM-DD').add(-2, 'd').toDate();
timeStamp = moment(timeStamp, 'YYYY-MM-DD').toDate();
const value = timeStamp >= currentDate ? true : false;
return {
'highlight': value,
'drawing-select': true
};
}
Try [class.className]=
, for example:
<mat-card [class.drawing-select]="true" [class.highlight]="outLine(c.UpdatedTimestamp)['highlight']" (click)="selectConfig(i)" fxLayout="column" fxLayoutAlign="center center" @fadeInAnimation>
<img src="{{ c.SignedUrl }}&width=200&height=150" />
<span>{{c.Content.Title}}</span>
</mat-card>
In another hand, sometimes fxLayoutAlign
directive reset dynamic Class values.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments