Stefan Stefan - 3 months ago 23
Javascript Question

Is there a way to modify content being pasted in textAngular?

When someone pastes content copied from a website or even a word document, textAngular adds additional break

tags before and after the content.

I'm using textAngular like this:

<text-angular name="summary" ng-model="summary" ta-paste="trimTags($html)" required>

What I'd like to do is somehow trim the leading and trailing

The first approach I tried was writing a regex that will trim 2 leading and trailing


This works, but the changes are NOT reflected in the text presented. Is there a way to pass this
being pasted and reflect the changes after modifying it?

Alternatively, I tried the ng-change approach, with no luck since it pastes the actual code, sometimes mixing
tags it adds.

Another problem is that, you could paste something in the middle of the text, which makes detecting changes difficult and time consuming.


A silly overlook, if anyone has trouble with this, use the ta-paste and the regex from the question, and after modifying the content simply return it.

$scope.trimTags = function(content){
    //process the content
    return content;