I am attempting to display ellipses in a multi-line block using Angular, but I am encountering the following problem.
component.html
<div class="test" [innerHtml]="anchor1.length >= 200 ? anchor1.substring(0,242) + '...' : anchor"></div>
component.ts
anchor1 = 'Lorem ipsum dolor sit amet, id nam probo vidisse feugait.Lorem ipsum dolor sit amet, id nam probo vidisse feugait. Liber invenire expetendis eu duo, constituto assueverit ex mei. Mea ea quot mundi. <a href="abcdefghi.com">Test</a> <a href="#">test 2</a>';
stackblitz: https://stackblitz.com/edit/angular-ksgxdj
The desired output should be "Test..." but instead it is displaying as "Test" at the end of the line.
Given that the anchor tags can appear anywhere in the text, I have used substring and hardcoded values to simulate the scenario.
In this situation, Angular is rendering:
Lorem ipsum dolor etc etc <a href="abcdefghi.com">Test</a> <a href="#"...
Which is then truncated to:
Lorem ipsum dolor etc etc <a href="abcdefghi.com">Test</a>