Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to assign distinct scss classes to a div depending on a condition

I have a chat app, and I’m trying to show the messages from X user on the right side of the screen while having the other messages appear on the left.

      <ion-item *ngFor="let message of messages | slice: 0:messages.length" class="msg">
          <div *ngIf="this.message.user === this.user; else other" class="mine">
            <ion-row class="own">
              <ion-text color="tertiary"><b>{{ message.user }}: &nbsp;</b></ion-text>
              <ion-text color="secondary"> {{ message.text }}</ion-text>
            </ion-row></div>
          <ng-template #other>
            <ion-row class="other">
              <ion-text color="primary"><b>{{ message.user }}: &nbsp;</b></ion-text>
              <ion-text> {{ message.text }}</ion-text>
            </ion-row>
          </ng-template>
      </ion-item>
    </div>```
I tried using the displayflex, but I only achieved to move all the messages, not only mine

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Like this I would presume ?

<ion-row [ngClass]="message.user === user ? 'own' : 'other'">
<ion-row [class]="message.user === user ? 'own' : 'other'">
<ion-row class="{{ message.user === user ? 'own' : 'other' }}">
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading