I've been working on an app using the Ionic Framework. I am trying to figure out how to detect when a word is pressed in my application. One solution I tried involved splitting the string into words and generating a span with a click event for each one, as outlined in this post.
The issue arises when dealing with strings that contain a large number of words: hundreds or even thousands. Generating so many spans with individual click events can be resource-intensive and slow down the performance of the app (as I have already observed during testing).
Is there an alternative method to capture a click event and retrieve the clicked word without the need to create numerous spans?
I should clarify that I do not require any special highlighting effect, only the ability to fetch the clicked word as a string.
Any suggestions or insights on this matter would be greatly appreciated.