I need help with on click function in Angular 4. I've got such an element:
<mat-cell *matCellDef="let row">
<span>{{row.messageText | hasString}}</span>
<span *ngIf="row.messageText && row.messageText.length >= 30"><span class="show-more" (click)="showMore(row)">more</span></span>
</mat-cell>
I have a string in table cell from row.messageText, which is cut into shorter string by *ngIf directive. If length of the string is too much, I shorten it by substr() function. and display in the table cell. I also add a "more" span to it so I can click on it and expand this string.
And there is my problem - what can I do so I can click on "more" and show entire length of this string? My idea is to bind on click function to span "show more" and return a full string.
This is the function in my component .ts file:
showMore(row) {
return row.messageText.substr();
}
The function returns full string. How can I apply this to my component.html?