Richard Richard - 1 year ago 107
CSS Question

CSS changing style

I am using Ionic2, and have and

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">

Can anyone please suggest a way yo achieve this?


Answer Source

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'">
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download