I have text and some words in text are with spaces like I like R O S E S and trees. Spaces are made with help of this function
this.text = this.text.replace(new RegExp(this.words.join('|'), 'g'), function insertSpaces(x) {
return x.split('').join(' ');
}); };
where text is I like roses and trees and word is ROSES, I would like to make it possible to click on the word R O S E S between letters and if I click there appears "-"instead of spaces. So, if I click between R and O there appears R-O S E S instead of R O S E S, if I click between O and S, appears R O-S E S instead of R O S E S and so on...is it possible with Angular2?
UPDATE
I try this code now
getCaretPos(oField: any, a: any) {
if (oField.selectionStart || oField.selectionStart === '0') {
this.caretPos = oField.selectionStart;
//assign char at choosed position to new variable
a = this.text.charAt(this.caretPos);
//replace this char with "-"
this.text.replace(a, '-');
}
}
}