Read more/less "Text Toggle" implementation?

Hi everybody!

how is it possible to implement a text toggle e.g. read more/less like in this post?:

I found no solution for Ionic 2/Angular 2. I would be glad about the simplest implementation.

Kind regards,

Here’s something Q&D that should at least get you started, using ng2-truncate:

export class TruncatedTextComponent {
  @Input() text: string;
  @Input() limit: number = 40;
  truncating = true;

<div *ngIf="text">
<div *ngIf="text.length <= limit">{{text}}</div>
<div *ngIf="truncating && text.length > limit">
  {{text | truncate : limit}}
  <button ion-button (click)="truncating = false">show more</button>
<div *ngIf="!truncating && text.length > limit">
  <button ion-button (click)="truncating = true">show less</button>


<ion-input [(ngModel)]="lorem"></ion-input>
<truncated-text [text]="lorem" limit="20"></truncated-text>

It works. Thanks a lot!