1

Hello i want to set the background color for an ion-card. I am returning an Object has has a property named color and this property has values on db table the predefined colors on variables.scss (primary, secondary, tertiary, dark etc...),. The object's name is userInterests. userInterests.color is the property that has the values (primary, secondary, tertiary)

<ion-col size="6" *ngFor="let item of usersInterest;">
          <ion-card id="card">
            <ion-avatar>
            <img [defaultImage]="defaultImage" [lazyLoad]="item.profile_pic"/>
          </ion-avatar>
            <div class="card2"><div><br /><br /><br /><br /><br /><br /><br /><br /></div>
              <div class="card-title">{{item?.first_name || item?.username }}</div>
              <div class="card-subtitle">{{item?.artisticBehaviour}}</div>
            </div>
        </ion-card>
2

1 Answer 1

1

You may want to use string interpolation to define the card's color. Your example is slightly confusing; maybe you want item.color instead of userInterests.color.

<ion-card color="{{userInterests.color}}">
  //...
</ion-card>

Documentation: https://ionicframework.com/docs/api/card#colors

1
  • As simple as that. I was trying to go from Greece to Italy via China. Duh..... Thanks Joosep
    – SimonIoa
    Feb 27 at 17:06

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.