How to dynamic change ion-item layout


#1

Hi,

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!


#2

By using a combination of ngClass and ngIf:

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

In the controller

$scope.showIcon = true;

#3

Works like a charm! Thanks a lot:)


#4

Hi,

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.