简体   繁体   中英

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>

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM