How to dynamic change ion-item layout


I have a ion-list with ng-repeat ion-item(class=“item-avatar item-icon-right”), how can I dynamic change item-icon-right to icon or span text by controller?

Thanks for your help!

By using a combination of ngClass and ngIf:

<ion-item class="item-avatar" ng-class="{'item-icon-right': showIcon}">
  <i ng-if="showIcon" class="icon ion-star"></i>
  <span ng-if="!showIcon">Span text</span>

In the controller

$scope.showIcon = true;
1 Like

Works like a charm! Thanks a lot:)

1 Like


I want to change my style in some specific ion-card s that have an specific property in the object list from the typescript class using Ionic 2. How can I do that?

Thanks for your help.