I have an application where I want to make an editing area, just like this one on StackOverflow. I don't want to use the textAngular directive, because it's too hard to understand, so I found about this Javascript function, document.execCommand, which it seems to be exactly what I need.
The problem is that I can't make it work in AngularJs. It's not giving any error, it just doesn't do anything.
I have a content editable div:
<div contenteditable id="text"><h5>Select a part of this text!</h5></div>
a Bold button:
<i class="fa fa-bold" ng-click="wrapBold()"></i>
and the function:
$scope.wrapBold = function() {
document.execCommand('bold', false, null);
};
I have tried with $document
, which I injected in the controller, but then it gives me an error saying
TypeError: undefined is not a function at Scope.$scope.wrapBold
Aucun commentaire:
Enregistrer un commentaire