Ionic 2/3 checking if label text is being truncated or not to use it as condition


#1

I have these labels and this button

...let item of items...
<ion-label *ngIf="item.textwrap" text-wrap>{{item.record_view}}
</ion-label>
<ion-label *ngIf="!(item.textwrap)" >{{item.record_view}}
</ion-label>
<button ion-button (click)="textWrap(item)" clear item-right >
    <ion-icon name="more"></ion-icon>
</button>

The purpose of this code is to show all the text if the button is pressed.
This solution is not elegant at all and I don’t like it at all, but after ages of searches I’ve got only to that.

I would better like to add the button only if label text is being actually truncated, something like:

<ion-label [ngStyle]="ITEM.WRAPTEXT" >{{item.record_view}}
</ion-label>
<button ion-button *ngIf="IS_LABEL_TRUNCATED" (click)="textWrap(item)" clear item-right >
    <ion-icon name="more"></ion-icon>
</button>

using state variables in the .ts file like

textWrap(item){
  if(item.textwrap==""{
    item.textwrap = "text-wrap" //or true
  }else{
    item.textwrap = "" //or false
  }
}

Do you guys have any solution to achieve such a result?

thanks to everybody