Is there a way to extract only the initial line or first 50 words from the data retrieved by the API and store it in a variable?
In the HTML File:
<td *ngIf="customizedColumns?.details_of_non_conformity?.value">
<span [ngClass]="{'closeLine': rpt.isDeleted == 1}">
<span [tooltip]="popTemplateToolTip"
triggers="mouseenter:mouseleave"
(mouseenter)="mouseEnterToolTip(rpt.detailsOfNonConformity)"
(mouseleave)="mouseLeaveToolTip()"
*ngIf="rpt.detailsOfNonConformity">
<span>{{helperService.removeUnwantedHTMLWithTags(rpt?.detailsOfNonConformity) | truncate:30}}</span>
</span>
</span>
</td>
In the TS File:
mouseEnterToolTip(data) {
this.toolTipHtml = data.split('.')[0];
this.toolTipHtml = this.helperService.removeUnwantedHTMLWithTags(this.toolTipHtml);
}
mouseLeaveToolTip() {
this.toolTipHtml = "";
}
I attempted to retrieve the first line from the variable data
, using
this.toolTipHtml = data.split('\n')[0];
. However, this approach did not yield the desired result.