I have a string and when i click on any word in a string then it should give another string from that clicked word onward back to the start of the string i.e.
str = 'this is a test string.' After click on "test" word, the new string should be like that 'this is a test' etc.
Currently, When I select the whole word then it gives the expected result but not on 'click'.
Also, in the following link they give the solution but it is in jquery and I want to implent in Anguar 10
app.component.html
<textarea class="form-control rows=10 cols=50 cstm-textarea" (click)="TargetPrefix($event)">
This is a test string
</textarea>
app.component.ts
TargetPrefix(event) {
const start = event.target.selectionStart;
const end = event.target.selectionEnd;
const result = event.target.value.substr(end - start, start);
console.log("the clicked word in the string", result);
}
[enter image description here][1] [enter image description here][2]
Thank you
onClick [1]: https://i.stack.imgur.com/qjwKO.jpg
Select [2]: https://i.stack.imgur.com/SG6zT.jpg