0

I'm developing an app using Ionic Framework. In my app I want to detect when a word was pressed. I tried to adapt and implement this solution, where you split the string in words and generate a span with a click event for every word.

The problem comes when the string contains a large number of words: hundreds or thousands, and generating so many spans with a click event would take more memory and time (besides as I already tested, the application moves quite slow on a large string).

So is there any other way to get a click event that would return the clicked word, without generating lots of spans?

I mention that I do not need to obtain a highlight effect, only to get the clicked word as a string.

Any help or idea would be much appreciated.

snecserc
  • 615
  • 1
  • 6
  • 19

1 Answers1

0
<div>This is a simple example.</div>

click function refer in this link

In that function return index you can find out that word use regex "space" start and end.

sorry for bad English

  • I added that script in my html file, but no log in the console. However I would need an angular function that I could implement in the `.ts` file, not just a script in the html page. – snecserc Jul 13 '17 at 14:44
  • AM given idea and basic things u need to analysis and implement. – Karvannan Thi Jul 14 '17 at 11:23