0

In AngularJS, how do we insert a text, for example, I Want to insert text at position 7 with word "My "

Before

<textarea type="text">This is Text</textarea> 

After

<textarea type="text">This is My Text</textarea> 

1 Answer 1

1

You can try something like this.

 $scope.text = $scope.insertText('This is Text', ' My', 7); $scope.insertText = function(source, text, position) { var subStr = source.substring(0, position); return subStr + text + source.substring(subStr.length); } <textarea type="text">{{text}}</textarea> 
Sign up to request clarification or add additional context in comments.

1 Comment

Hi Allabakash, it's working, I couldn't find that when searching, thank you :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.