0

so I have a pretty large component, that I am trying to make it as DRY as possible. However, I haven't found an easier way to do this: The parent is showing a list of child components, chat messages that I have active, and they can have three states:

  1. unread and urgent unread and normal
  2. read(no new messages)
  3. no new messages
<ion-grid>
  <ng-container *ngIf="unreadAndUrgent; else normal">
    <ion-row class="urgent">
      <!-- about 30-40 lines of further structuring -->
    </ion-row>
  </ng-container>
  <ng-template #normal>
    <ion-row [class]="unreadNormalMessages ? 'normal-css' : '' ">
      <!-- same 30-40 lines of further structuring as above -->
    </ion-row>
  </ng-template>
</ion-grid>

as you can see I am essentially repeating the same code as above which just makes it very bloated in the end and I am trying to cut it down so that it can be more DRY. Any suggestions? thanks!

1 Answer 1

2

you can use [ngClass]="{'class-name':condition,'class2-name':condition}"

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.