Angular 9 - ngClass not working correctly on production environment

HJ1990

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
    };
}
anlijudavid

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.

edited at
0

Comments

0 comments
Login to comment

Related

Angular 9 router redirect with ** not working correctly

Angular - ngClass is not working

NativeScript Angular ngClass is not working

Angular is not loading correctly in production

ngClass not working in my Angular Project

Geocoder Gem not working in Production Environment

ActionCable no longer working in production environment

jQuery tabs not working in production environment

angular2 Pipe expression on [ngClass] not working

Angular 4 conditional ngClass navbar not working

breadcrumbs with gretel gem working on dev environment but not working on production environment on Heroku

rails environment production not working no files loaded

Bootstrap JavaScript not working in production environment (Rails 4)

Google bucket file uploading not working in production environment

Java Filter not working on production environment Websphere 8.5

Rails 4: Image path not working in production environment

Gatsby Cloud environment variables not working in production

ngClass not working?

What is the difference between [ngClass]/[class] and [className] in Angular 9?

Vuetify/Nuxt Production environment components not working as suppose in dev environment

Angular 2 and Team City Production/Environment Variables

Access environment variables in production build Angular 4

Saving Postman environment variables not working correctly?

Angular translation not working with angular 9

Angular Material not Working in Angular 9

nginx + angular 9 error in production for mobile browsers

9 Patch png not working correctly for background

Angular not working correctly with Meteor 1.3.1

DatePipe is not working correctly in Angular 6