Richard Richard - 15 days ago 5
CSS Question

CSS changing style

I am using Ionic2, and have and

ion-content
tag. Depending on a variable, I want to change the style on the tag.

I have tried the following, but it does not work:

<ion-content *ngIf="persoModel.type === 0" padding class="person-content-wanted">
<ion-content *ngIf="personModel.type === 1" padding class="person-content-offered">
...
</ion-content>


Can anyone please suggest a way yo achieve this?

Thanks

Answer

here personModel is a boolean if it is true you will get person-content-wanted class if it is false you will get person-content-offerred

 <ion-content [ngclass]="personModel? 'person-content-wanted' : 'person-content-offered'">
Comments