xyonme
xyonme

Reputation: 395

AngularJS Render HTML in textarea

I need to render HTML values in text area SUBMIT FORM. I can bind the html values in a <div> but not in a <textarea>. Also, ng-model for data binding can retrieve the value but it is displayed as html.

Controller

//task.descr contains "<br>-------<br><a href="http://www.google.com"..."
var str="<br><hr><br>"+ task.descr;
//str= $sce.trustAsHtml(str);
$scope.formData5 = {
    descr: str}
console.log($scope.formData5);


<textarea placeholder="Deskripsi Memo"  name="descr" 
ngMaxlength="1000" ng-model="formData5.descr" 
ng-bind-html="formData5.descr" > </textarea>

Upvotes: 2

Views: 13952

Answers (1)

mohamedrias
mohamedrias

Reputation: 18566

This would allow you have both two way data binding as well as give you the functionality of textarea:

  <div ng-bind-html="modelname"
         contenteditable="true"
         ng-model="modelname">
    </div>

DEMO

Upvotes: 5

Related Questions