When press on word get this word from <p>

hi , i have app that show a text i want when the user press or touch one of these word get it back to the system

hi i'm sofe i'm new to ionic, and i love it so much

i want when i touch or press for example on "new" i want this word save on variable

bro you can try to take codes from stacks overflow you get more …new experience …


i didn’t find the concept that i want

can you please explain briefly your requirement brother… what you actually…

try this:
script code=>

var text = "This is my text"; // your text you want to display

var text_arr = text.split(" ");// convert to array

alert(text_clicked); // or do something else with the text

html code => display your text with on-click event, something like below

       <p><span *ngFor = "let myText as text_arr ; let i = index" (click)="getClicked({{ myText[i] }})"> {{ myText[i] }}</span></p>

I just created those chunks of code impromtu and haven’t checked it. Hope it helps.

i will try it now , thank u so much

i tried it, it works thank u so much, but it split the first word not all the graph

i figuerd what it the proplem
it should be like that:

  <p><span *ngFor = "let myText of text_arr ; let i = index" (click)="getClicked( myText )"> 
              {{ myText }}

thank u so much mister Cabz
u helped me sooooooo much

No problem. Glad to help.

1 Like